Documentation ¶
Overview ¶
Package sealeye is a library for command line interfaces.
See sealeye-example for complete examples of all the features, but a quick summary:
- Short options "-s" and long options "--long", with fallback to "-long" to support Go-like flags.
- Multiple option names per option.
- Boolean options can be flipped with "no" prefixing the long name, e.g. "--no-color".
- Environment variable defaults support.
- Multiple defaults support, for example "env:COUNT,123" which would use the option's value if the user set it, or the COUNT environment variable if that was set, or finally the plain value of 123 if all else failed.
- Subcommands using the exact same structures.
- Options grouping, for DRY reuse, by simple struct embedding.
- Markdown support for help text, reformatting to fit the terminal and using color if possible.
- Support for an --all-help option to output all help for all subcommands.
Things To Be Done Still:
- Support for other types: floats, times, durations, maybe lists.
- Handle --option=value format.
- Handle -abc to be the equivalent of -a -b -c but only for short options.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
func Run(cli interface{})
Run is the top-level sealeye handler. Usually, assuming your top-level command variable is named "root" this would be your main function:
func main() { sealeye.Run(root) }
func RunAdvanced ¶
func RunAdvanced(stdout FDWriter, stderr io.Writer, name string, cli interface{}, args []string) int
RunAdvanced is much like Run except that you can specify stdout, stderr, and the executable name and arguments yourself. Useful for tests, or an interactive shell that calls various embedded CLIs, etc. Additionally, RunAdvanced will not call os.Exit but will instead return the exit code to you.
Types ¶
Click to show internal directories.
Click to hide internal directories.