Skip to content

Instantly share code, notes, and snippets.

@fgblomqvist
Created July 11, 2016 13:47
Show Gist options
  • Save fgblomqvist/16336cec3377bf30223ecce11f1d2ff6 to your computer and use it in GitHub Desktop.
Save fgblomqvist/16336cec3377bf30223ecce11f1d2ff6 to your computer and use it in GitHub Desktop.
fgblomqvist:Desktop$ ./test help cmd
NAME:
test cmd -
USAGE:
test cmd [command options] [arguments...]
OPTIONS:
--flag1 value Foo
--flag2 value Bar
fgblomqvist:Desktop$ ./test cmd help
NAME:
test cmd -
USAGE:
test cmd [global options] command [command options] [arguments...]
VERSION:
0.0.0
COMMANDS:
test
GLOBAL OPTIONS:
--flag1 value Foo
--flag2 value Bar
--help, -h show help
fgblomqvist:Desktop$ ./test cmd -h
fgblomqvist:Desktop$ ./test cmd --help
fgblomqvist:Desktop$
package main
import (
"gopkg.in/urfave/cli.v1"
"os"
)
func main() {
app := cli.NewApp()
app.Commands = []cli.Command{
{
Name: "cmd",
Flags: []cli.Flag{
cli.StringFlag{
Name: "flag1",
Usage: "Foo",
},
cli.StringFlag{
Name: "flag2",
Usage: "Bar",
},
},
Action: func(c *cli.Context) error {
return nil
},
Subcommands: []cli.Command{
{
Name: "test",
},
},
},
}
app.Run(os.Args)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment