Skip to content

a simple library to build golang command line (cli / cmd)apps

License

Notifications You must be signed in to change notification settings

seastart/cli-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cli-go

中文帮助
a simple library to build golang command line (cli / cmd)apps

go get github.com/seastart/cli-go

respect cobra urfave cli

concepts

./app [-main_opt1=1] [command] [-cmd_opt1=1] [-cmd_opt2=2] [subcommands/args]

app is the application
command is sub command, no prefix -
opt is options, start with -
one app may have some main options, such as environment config, like main_opt1 of above example
one app may have some commands, like command of above example
one command may have some command options, like cmd_opt1 cmd_opt2 of above example
one command may have some subcommands(arguments), like subcommands of above example

steps (3 step)

  • app := cli.NewCliApp
  • app.AddCommand
  • app.Run

examples

./main
./main -start=2
./main
./main test -start=2
./main list -page=3
./main
./main test live
./main test -start=2 live
// set default env and then run list command
./main -env=prod list -page=3

default help command

each app have a default help command

./main help

TODO

  • support i18n
  • support persistentRun

About

a simple library to build golang command line (cli / cmd)apps

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages