Skip to content

Commit a311830

Browse files
committed
POC for item struct
Signed-off-by: Matt Stratton <matt.stratton@gmail.com>
1 parent b6683c8 commit a311830

3 files changed

Lines changed: 71 additions & 0 deletions

File tree

cmd/prompt.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cmd
33
import (
44
"github.com/AlecAivazis/survey"
55
"github.com/devopsdays/devopsdays-cli/event"
6+
"github.com/devopsdays/devopsdays-cli/model"
67
"github.com/devopsdays/devopsdays-cli/speaker"
78
"github.com/devopsdays/devopsdays-cli/sponsor"
89
"github.com/devopsdays/devopsdays-cli/talk"
@@ -20,6 +21,7 @@ func mainPrompt() (err error) {
2021
"Create a new sponsor",
2122
"Show a speaker",
2223
"Show a talk",
24+
"Test",
2325
"Quit the application",
2426
},
2527
}
@@ -38,6 +40,8 @@ func mainPrompt() (err error) {
3840
showSpeakerPrompt("", "")
3941
case "Show a talk":
4042
showTalkPrompt("", "")
43+
case "Test":
44+
model.ShowEvent()
4145
}
4246
}
4347

item/item.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Package item contains the types and methods for items like talks, events, sponsors, etc.
2+
package item
3+
4+
import "fmt"
5+
6+
// Item is the overall interface for the items (wow, that's terrible)
7+
type Item interface {
8+
Create(city, year string) (*struct{}, error)
9+
}
10+
11+
// Event is an event
12+
type Event struct {
13+
Name string `yaml:"name"`
14+
Year string `yaml:"year"`
15+
City string `yaml:"city"`
16+
EventTwitter string `yaml:"event_twitter"`
17+
Description string `yaml:"description"`
18+
GoogleAnalytics string `yaml:"ga_tracking_id"`
19+
StartDate string `yaml:"startdate"`
20+
EndDate string `yaml:"enddate"`
21+
CFPDateStart string `yaml:"cfp_date_start"`
22+
CFPDateEnd string `yaml:"cfp_date_end"`
23+
CFPDateAnnounce string `yaml:"cfp_date_announce"`
24+
CFPOpen string `yaml:"cfp_open"`
25+
CFPLink string `yaml:"cfp_link"`
26+
RegistrationDateStart string `yaml:"registration_date_start"`
27+
RegistrationDateEnd string `yaml:"registration_date_end"`
28+
RegistrationClosed string `yaml:"registration_closed"`
29+
RegistrationLink string `yaml:"registration_link"`
30+
MastheadBackground string `yaml:"masthead_background"`
31+
Coordinates string `yaml:"coordinates"`
32+
Location string `yaml:"location"`
33+
LocationAddress string `yaml:"location_address"`
34+
NavElements []string `yaml:"nav_elements"`
35+
TeamMembers []string `yaml:"team_members"`
36+
OrganizerEmail string `yaml:"organizer_email"`
37+
ProposalEmail string `yaml:"proposal_email"`
38+
Sponsors []string `yaml:"sponsors"`
39+
SponsorsAccepted string `yaml:"sponsors_accepted"`
40+
SponsorLevels []string `yaml:"sponsor_levels"`
41+
}
42+
43+
func (e *Event) Create(city, year string) (*Event, error) {
44+
myEvent := new(Event)
45+
myEvent.Name = "Hello"
46+
return myEvent, nil
47+
}
48+
49+
func ShowEvent() {
50+
e := new(Event)
51+
event, _ := e.Create("Ponyville", "2017")
52+
fmt.Println(event)
53+
}

model/event.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package model
22

3+
import "fmt"
4+
35
// Event defines a devopsdays event in the data yaml file
46
type Event struct {
57
Name string `yaml:"name"`
@@ -53,3 +55,15 @@ type SponsorLevel struct {
5355
Label string `yaml:"label"`
5456
Max int `yaml:"max,omitempty"`
5557
}
58+
59+
func (e *Event) Create(city, year string) (*Event, error) {
60+
myEvent := new(Event)
61+
myEvent.Name = "Hello"
62+
return myEvent, nil
63+
}
64+
65+
func ShowEvent() {
66+
e := new(Event)
67+
event, _ := e.Create("Ponyville", "2017")
68+
fmt.Println(event)
69+
}

0 commit comments

Comments
 (0)