8000 GitHub - posener/cmd at v1.0.0
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

posener/cmd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

subcmd

Build Status codecov GoDoc goreadme

subcmd is a minimalistic library that enables easy sub commands with the standard flag library.

Define a root command object using the Root function. This object exposes the standard library's flag.FlagSet API, which enables adding flags in the standard way. Additionally, this object exposes the SubCommand method, which returns another command object. This objects also exposing the same API, enabling definition of flags and nested sub commands.

The root object then have to be called with the Parse or ParseArgs methods, similiraly to the flag.Parse call.

The usage is automatically configured to show both sub commands and flags.

Example

See ./example/main.go.

Limitations

Suppose cmd has a flag -flag, and a subcommand sub. In the current implementation: Calling cmd sub -flag won't work as the flag is set after the sub command, while cmd -flag sub will work perfectly fine. Each flag needs to be used in the scope of its command.

Sub Packages


Created by goreadme

About

The standard library flag package with its missing features

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages

0