Turning cli into a package
This commit is contained in:
parent
e830a4195e
commit
372b86498f
36
cli.go
36
cli.go
@ -1,38 +1,4 @@
|
||||
package main
|
||||
|
||||
import "os"
|
||||
|
||||
func main() {
|
||||
App{
|
||||
Name: "math",
|
||||
Description: "a simple command line math utility",
|
||||
Commands: []Command{{
|
||||
Name: "add",
|
||||
Description: "Add 2 and 2",
|
||||
Action: func(name string) {
|
||||
println("2+2=", 2+2)
|
||||
},
|
||||
}, {
|
||||
Name: "subtract",
|
||||
Description: "Subtract 2 and 2",
|
||||
Action: func(name string) {
|
||||
println("2-2=", 2-2)
|
||||
},
|
||||
}, {
|
||||
Name: "multiply",
|
||||
Description: "Multiply 2 and 2",
|
||||
Action: func(name string) {
|
||||
println("2*2=", 2*2)
|
||||
},
|
||||
}, {
|
||||
Name: "divide",
|
||||
Description: "Divide 2 and 2",
|
||||
Action: func(name string) {
|
||||
println("2/2=", 2/2)
|
||||
},
|
||||
}},
|
||||
}.Run(os.Args[1])
|
||||
}
|
||||
package cli
|
||||
|
||||
type App struct {
|
||||
Name string
|
||||
|
Loading…
Reference in New Issue
Block a user