# README
cli: building better command line interfaces
cli is a Golang package intended to encourage a more consistant command line user interface in programs written for Caltech Library using Go.
Features include:
- Code generation for a command line tool
- Integrated support for generating Markdown docs from a cli program
- Integrated support for generating man pages from a cli program
- Short/Long option (flag) support for both the command and verbs
Command line tools
Two command line tools come with the cli package.
- cligenerate - will generate a skelton command line program
- pkgassets - will take Markdown docs and create a go program file where each doc's name is the key and contents are the byte array value representing the docs
# Functions
CloseFile accepts a filename and os.File pointer, if filename is "" or "-" it skips the close otherwise is does a fp.Close() on the file.
Create accepts a filename, fallbackFile (usually os.Stdout, os.Stdin, os.Stderr) and returns a file pointer and error.
ExitOnError is used by the cli programs to handle exit cuasing errors constitantly.
Generate creates main.go source code.
IsPipe accepts a file pointer and returns true if data on file pointer is from a pipe or false if not.
NewCli creates an Cli instance, an Cli describes the running of the command line interface making it easy to expose the functionality in packages as command line tools.
NewVerb creates an Verb instance, and describes the running of the command line interface making it easy to expose the functionality in packages as command line tools.
OnError writes an error message to out if err != nil taking into consideration the state of quiet.
Open accepts a filename, fallbackFile (usually os.Stdout, os.Stdin, os.Stderr) and returns a file pointer and error.
PopArg takes an array pops the last element returning the element and an updated array.
PushArg takes and array and adds a string to the end.
ReadLines accepts a file pointer to read and returns an array of lines.
ShiftArg takes an array of strings and if array is not empty returns a string and the rest of the args.
Unshift takes a string and an array of strings and returns a new array with the value of string as the first element and the rest are elements of the array of strings.
# Structs
Cli models the metadata for running a common cli program.
EnvAttribute describes expected environmental attributes associated with the cli app.
Verb holds the metadata for an keyword action associated with a cli.