This repository has been archived by the owner on Apr 4, 2024. It is now read-only.
/
sponsor.go
140 lines (118 loc) · 4.14 KB
/
sponsor.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package commands
import (
"fmt"
"github.com/spf13/cobra"
)
// sponsorCmd represents the sponsor command
var sponsorCmd = &cobra.Command{
Use: "sponsor [name]",
Short: "Create a sponsor",
Long: `Create a new sponsor file add the sponsor's image.
The name argument must not contain any spaces.
`,
Example: ` devopsdays-cli create sponsor
devopsdays-cli create sponsor bluth-company`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) > 0 {
addSponsor(args[0])
} else {
addSponsor("")
}
},
}
// addSponsorCmd represents the "add sponsor" command
var addSponsorCmd = &cobra.Command{
Use: "sponsor",
Short: "Add a sponsor to an event",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
addSponsor("") // This is the fake one
},
}
// createSponsorCmd represents the "create sponsor" command
var createSponsorCmd = &cobra.Command{
Use: "sponsor [name]",
Short: "Create a sponsor",
Long: `Create a new sponsor file add the sponsor's image.
The name argument must not contain any spaces.
`,
Example: ` devopsdays-cli create sponsor
devopsdays-cli create sponsor bluth-company`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) > 0 {
addSponsor(args[0])
} else {
addSponsor("")
}
},
}
// editSponsorCmd represents the "edit sponsor" command
var editSponsorCmd = &cobra.Command{
Use: "sponsor",
Short: "Create a new sponsor",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly edit a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
editSponsor()
},
}
// removeSponsorCmd represents the "remove sponsor" command
var removeSponsorCmd = &cobra.Command{
Use: "sponsor",
Short: "Remove a sponsor from an event",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
removeSponsor() // This is the fake one
},
}
// showSponsorCmd represents the "show sponsor" command
var showSponsorCmd = &cobra.Command{
Use: "sponsor",
Short: "Remove a sponsor from an event",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
showSponsor() // This is the fake one
},
}
func init() {
// RootCmd.AddCommand(sponsorCmd)
addCmd.AddCommand(addSponsorCmd)
createCmd.AddCommand(createSponsorCmd)
editCmd.AddCommand(editSponsorCmd)
removeCmd.AddCommand(removeSponsorCmd)
showCmd.AddCommand(showSponsorCmd)
addSponsorCmd.Flags().StringVarP(&City, "city", "c", "", "city to use")
addSponsorCmd.Flags().StringVarP(&Year, "year", "y", "", "year to use")
removeSponsorCmd.Flags().StringVarP(&City, "city", "c", "", "city to use")
removeSponsorCmd.Flags().StringVarP(&Year, "year", "y", "", "year to use")
showSponsorCmd.Flags().StringVarP(&City, "city", "c", "", "city to use")
showSponsorCmd.Flags().StringVarP(&Year, "year", "y", "", "year to use")
}
// Main functions go down here
func addSponsor(sponsor string) {
fmt.Println("You would have added a sponsor if this happened")
}
func editSponsor() {
fmt.Println("You would have edited an existing sponsor if this happened")
}
func removeSponsor() {
fmt.Println("You would have removed a sponsor from the event if this happened")
}
func showSponsor() {
fmt.Println("You would have shown a sponsor if this happened")
}