Skip to content

Instantly share code, notes, and snippets.

@tmtk75
Created December 21, 2014 14:14
Show Gist options
  • Save tmtk75/962def1a20ed23395e98 to your computer and use it in GitHub Desktop.
Save tmtk75/962def1a20ed23395e98 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"os"
"github.com/tmtk75/cli"
)
func main() {
app := cli.NewApp()
app.Commands = []cli.Command{
cli.Command{
Name: "cat",
Subcommands: []cli.Command{
cli.Command{
Name: "dog",
Args: "<id> [path] [name]",
Action: func(c *cli.Context) {
id, _ := c.ArgFor("id")
path, a := c.ArgFor("path")
name, b := c.ArgFor("name")
fmt.Printf("%v, %v:%v, %v:%v\n", id, path, a, name, b)
},
},
},
},
}
app.Run(os.Args)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment