2013-07-20 22:50:13 +00:00
|
|
|
package cli_test
|
2013-07-19 00:29:06 +00:00
|
|
|
|
|
|
|
import (
|
2013-07-20 22:50:13 +00:00
|
|
|
"github.com/codegangsta/cli"
|
|
|
|
"os"
|
2013-07-19 00:29:06 +00:00
|
|
|
)
|
|
|
|
|
2013-07-20 22:50:13 +00:00
|
|
|
func Example() {
|
|
|
|
app := cli.NewApp()
|
|
|
|
app.Name = "todo"
|
|
|
|
app.Usage = "task list on the command line"
|
|
|
|
app.Commands = []cli.Command{
|
2013-07-19 02:17:33 +00:00
|
|
|
{
|
2013-07-20 22:50:13 +00:00
|
|
|
Name: "add",
|
|
|
|
ShortName: "a",
|
|
|
|
Usage: "add a task to the list",
|
|
|
|
Action: func(c *cli.Context) {
|
2013-11-24 13:40:21 +00:00
|
|
|
println("added task: ", c.Args().First())
|
2013-07-19 02:17:33 +00:00
|
|
|
},
|
2013-07-20 22:50:13 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "complete",
|
|
|
|
ShortName: "c",
|
|
|
|
Usage: "complete a task on the list",
|
|
|
|
Action: func(c *cli.Context) {
|
2013-11-24 13:40:21 +00:00
|
|
|
println("completed task: ", c.Args().First())
|
2013-07-19 02:17:33 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2013-07-19 00:29:06 +00:00
|
|
|
|
2013-07-20 22:50:13 +00:00
|
|
|
app.Run(os.Args)
|
2013-07-19 00:29:06 +00:00
|
|
|
}
|