Got a semi working command line setup.

This commit is contained in:
Jeremy Saenz 2013-07-13 12:30:21 -07:00
parent 460c0de4ea
commit 360e387071

10
cli.go
View File

@ -1,5 +1,7 @@
package main
import "os"
func main() {
app := App{
Name: "math",
@ -22,7 +24,7 @@ func main() {
Description: "Divide 2 and 2",
Action: DoDivide}}}
app.Run("add")
app.Run(os.Args[1])
}
func DoAdd(name string) {
@ -56,5 +58,9 @@ type Command struct {
type Action func(name string)
func (a App) Run(command string) {
a.Commands[0].Action(a.Commands[0].Name)
for _, c := range a.Commands {
if(c.Name == command) {
c.Action(command)
}
}
}