Created
July 11, 2016 13:47
-
-
Save fgblomqvist/16336cec3377bf30223ecce11f1d2ff6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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