You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Long: `Create a new sponsor file, and optionally add the sponsor's image.
24
-
The name argument must not contain any spaces.`,
13
+
Long: `Create a new sponsor file add the sponsor's image.
14
+
The name argument must not contain any spaces.
15
+
`,
16
+
Example: ` devopsdays-cli create sponsor
17
+
devopsdays-cli create sponsor bluth-company`,
25
18
Run: func(cmd*cobra.Command, args []string) {
26
19
27
20
iflen(args) >0 {
@@ -44,23 +37,26 @@ This application is a tool to generate the needed files
44
37
to quickly create a Cobra application.`,
45
38
Run: func(cmd*cobra.Command, args []string) {
46
39
// TODO: Work your own magic here
47
-
addSponsorFake() //TODO: This is the fake one
40
+
addSponsor("") //TODO: This is the fake one
48
41
},
49
42
}
50
43
51
44
// createSponsorCmd represents the "create sponsor" command
52
45
varcreateSponsorCmd=&cobra.Command{
53
-
Use: "sponsor",
54
-
Short: "Create a new sponsor",
55
-
Long: `A longer description that spans multiple lines and likely contains examples
56
-
and usage of using your command. For example:
57
-
58
-
Cobra is a CLI library for Go that empowers applications.
59
-
This application is a tool to generate the needed files
60
-
to quickly create a Cobra application.`,
46
+
Use: "sponsor [name]",
47
+
Short: "Create a sponsor",
48
+
Long: `Create a new sponsor file add the sponsor's image.
49
+
The name argument must not contain any spaces.
50
+
`,
51
+
Example: ` devopsdays-cli create sponsor
52
+
devopsdays-cli create sponsor bluth-company`,
61
53
Run: func(cmd*cobra.Command, args []string) {
62
-
// TODO: Work your own magic here
63
-
createSponsor()
54
+
55
+
iflen(args) >0 {
56
+
addSponsor(args[0])
57
+
} else {
58
+
addSponsor("")
59
+
}
64
60
},
65
61
}
66
62
@@ -131,14 +127,10 @@ func init() {
131
127
132
128
// Main functions go down here
133
129
134
-
funcaddSponsorFake() {
130
+
funcaddSponsor(sponsorstring) {
135
131
fmt.Println("You would have added a sponsor if this happened")
136
132
}
137
133
138
-
funccreateSponsor() {
139
-
fmt.Println("You would have created a new sponsor if this happened")
140
-
}
141
-
142
134
funceditSponsor() {
143
135
fmt.Println("You would have edited an existing sponsor if this happened")
144
136
}
@@ -150,143 +142,3 @@ func removeSponsor() {
150
142
funcshowSponsor() {
151
143
fmt.Println("You would have shown a sponsor if this happened")
152
144
}
153
-
154
-
funcaddSponsor(sponsorstring) (errerror) {
155
-
156
-
reader:=bufio.NewReader(os.Stdin)
157
-
ifsponsor=="" {
158
-
fmt.Println("Enter the sponsor's name. It must not contain any spaces: ")
159
-
sponsor, _=reader.ReadString('\n')
160
-
}
161
-
// Check if the sponsor exists already
162
-
ifcheckSponsor(sponsor) ==true {
163
-
returnerrors.New("Sponsor already exists. Try adding it again, perhaps appending '-YYYY'\nFor example, 'chef-2017'")
164
-
}
165
-
// prompt for the path to the sponsor image file
166
-
fmt.Println("Optional: Enter the path to the sponsor's image. It must be the full path. For example: `/Users/mattstratton/chef.png`. Enter return to add the sponsor image manually later.")
167
-
sponsorImage, _:=reader.ReadString('\n')
168
-
ifsponsorImage=="\n" {
169
-
fmt.Println("No sponsor image entered. Be sure to copy it to the path ", sponsorImagePath(webdir, sponsor), "later.")
0 commit comments