Documentation
¶
Overview ¶
Package cli processes default environment values, log handling, version number and other common code blocks used to implement cli tools.
@author R. S. Doiel, <rsdoiel@gmail.com> copyright (c) 2015 all rights reserved. Released under the Simplified BSD License. See: http://opensource.org/licenses/BSD-2-Clause
Index ¶
Constants ¶
This section is empty.
Variables ¶
var CommandName = func(s string) string { return filepath.Base(s) }
CommandName takes a path and returns the basename of the command.
var Usage = func(exit_code int, body string, msg string) { var fh = os.Stderr if exit_code == 0 { fh = os.Stdout } fmt.Fprintf(fh, `%s USAGE %s [options] %s OPTIONS `, msg, CommandName(os.Args[0]), body) flag.VisitAll(func(f *flag.Flag) { fmt.Fprintf(fh, "\t-%s\t(defaults to %s) %s\n", f.Name, f.DefValue, f.Usage) }) fmt.Fprintf(fh, ` copyright (c) 2014 all rights reserved. Released under the Simplified BSD License See: http://opensource.org/licenses/bsd-license.php `) os.Exit(exit_code) }
Usage info for the command
Version info for the command
Functions ¶
func DefaultEnvBool ¶
DefaultEnvBool returns the environment boolean value or default if not set.
func DefaultEnvInt ¶
DefaultEnvInt returns the environment value of the string or the default if not set.
func DefaultEnvString ¶
DefaultEnvString returns the environment value of the string or the default if not set.
Types ¶
This section is empty.