cli

package module
v0.0.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2021 License: BSD-3-Clause Imports: 13 Imported by: 60

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

Documentation

Overview

*

  • cli is a package intended to encourage some standardization in the
  • command line user interface for programs developed for Caltech Library. *
  • @author R. S. Doiel, <rsdoiel@library.caltech.edu> *
  • Copyright (c) 2021, Caltech
  • All rights not granted herein are expressly reserved by Caltech. *
  • Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: *
  • 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. *
  • 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. *
  • 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. *
  • THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *

*

  • cli is a package intended to encourage some standardization in the command line user interface for programs
  • developed for Caltech Library. *
  • @author R. S. Doiel, <rsdoiel@caltech.edu> *
  • Copyright (c) 2021, Caltech
  • All rights not granted herein are expressly reserved by Caltech. *
  • Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: *
  • 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. *
  • 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. *
  • 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. *
  • THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *

generator.go - provides a quick and dirty skeleton for cli based apps.

manpage.go - adds man page output formatting suitable for running through `nroff -man` and rendering a man page. It is a part of the cli page.

Author: R. S. Doiel, <rsdoiel@library.caltech.edu>

Copyright (c) 2021, Caltech All rights not granted herein are expressly reserved by Caltech.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

markdown.go - this is a part of the cli package. This code focuses on generating Markdown docs from the internal help information.

usage.go - handles rendering the "usage" message for cli package

*

  • cli is a package intended to encourage some standardization in the
  • command line user interface for programs developed for Caltech Library. *
  • @author R. S. Doiel, <rsdoiel@library.caltech.edu> *
  • Copyright (c) 2021, Caltech
  • All rights not granted herein are expressly reserved by Caltech. *
  • Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: *
  • 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. *
  • 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. *
  • 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. *
  • THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *

Index

Constants

View Source
const (
	LicenseText = `` /* 1530-byte string literal not displayed */

)
View Source
const Version = "0.0.18"

Variables

This section is empty.

Functions

func CloseFile

func CloseFile(filename string, fp *os.File) error

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.

func Create

func Create(filename string, fallbackFile *os.File) (*os.File, error)

Create accepts a filename, fallbackFile (usually os.Stdout, os.Stdin, os.Stderr) and returns a file pointer and error. It is a conviences function for wrapping stdin, stdout, stderr If filename is "-" or filename is "" then fallbackFile is used.

func ExitOnError

func ExitOnError(out *os.File, err error, quiet bool)

ExitOnError is used by the cli programs to handle exit cuasing errors constitantly. E.g. it respects the -quiet flag past to it.

func Generate added in v0.0.13

func Generate(appName, synopsis, author, descriptionFName, examplesFName, bugsFName, licenseFName string) []byte

Generate creates main.go source code

func IsPipe

func IsPipe(in *os.File) bool

IsPipe accepts a file pointer and returns true if data on file pointer is from a pipe or false if not.

func OnError

func OnError(out *os.File, err error, quiet bool)

OnError writes an error message to out if err != nil taking into consideration the state of quiet

func Open

func Open(filename string, fallbackFile *os.File) (*os.File, error)

Open accepts a filename, fallbackFile (usually os.Stdout, os.Stdin, os.Stderr) and returns a file pointer and error. It is a conviences function for wrapping stdin, stdout, stderr If filename is "-" or filename is "" then fallbackFile is used.

func PopArg

func PopArg(args []string) (string, []string)

PopArg takes an array pops the last element returning the element and an updated array. If no elements are left then a empty string and nil are turned.

func PushArg added in v0.0.13

func PushArg(s string, args []string) []string

PushArg takes and array and adds a string to the end

func ReadLines

func ReadLines(in *os.File) ([]string, error)

ReadLines accepts a file pointer to read and returns an array of lines.

func ShiftArg added in v0.0.13

func ShiftArg(args []string) (string, []string)

ShiftArg takes an array of strings and if array is not empty returns a string and the rest of the args. If array is empty it returns an empty string, when there are no more args it returns nil for the arg parameter

func UnshiftArg added in v0.0.13

func UnshiftArg(s string, args []string) []string

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

Types

type Cli

type Cli struct {
	// In is usually set to os.Stdin
	In *os.File
	// Out is usually set to os.Stdout
	Out *os.File
	// Eout is usually set to os.Stderr
	Eout *os.File
	// Documentation specific help pages, e.g. -help example1
	Documentation map[string][]byte
	// SectionNo is the numeric value section value for man page generation
	SectionNo int

	// VerbsRequired is true then USAGE line shows VERB rather than [VERB]
	VerbsRequired bool
	// contains filtered or unexported fields
}

Cli models the metadata for running a common cli program

func NewCli

func NewCli(version string) *Cli

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.

func (*Cli) AddHelp

func (c *Cli) AddHelp(keyword string, usage []byte) error

AddHelp takes a string keyword and byte slice of content and updates the Documentation attribute

func (*Cli) AppName

func (c *Cli) AppName() string

AppName returns the application name as a string

func (*Cli) Arg

func (c *Cli) Arg(i int) string

Arg returns an argument by pos index

func (*Cli) Args

func (c *Cli) Args() []string

Args returns flag.Args()

func (*Cli) BoolVar

func (c *Cli) BoolVar(p *bool, names string, value bool, usage string)

BoolVar updates c.options doc strings, then splits options and calls flag.BoolVar()

func (*Cli) DurationVar

func (c *Cli) DurationVar(p *time.Duration, names string, value time.Duration, usage string)

DurationVar updates c.options doc strings, then splits options and calls flag.DurationVar()

func (*Cli) Env

func (c *Cli) Env(name string) string

Env returns an EnvAttribute documentation string for matching name

func (*Cli) EnvAttribute

func (c *Cli) EnvAttribute(name string) (*EnvAttribute, error)

EnvAttribute returns the struct corresponding to the matchine name

func (*Cli) EnvBool

func (c *Cli) EnvBool(name string, value bool, usage string) *bool

EnvBool adds an environment variable which is evaluate before evaluating options returns a pointer to the value.

func (*Cli) EnvBoolVar

func (c *Cli) EnvBoolVar(p *bool, name string, value bool, usage string) error

EnvBoolVar adds environment variable which is evaluate before evaluating options It is the environment counterpart to flag.BoolVar()

func (*Cli) EnvDuration

func (c *Cli) EnvDuration(name string, value time.Duration, usage string) *time.Duration

EnvDuration adds environment variable which is evaluate before evaluating options It is the environment counterpart to flag.DurationVar()

func (*Cli) EnvDurationVar

func (c *Cli) EnvDurationVar(p *time.Duration, name string, value time.Duration, usage string) error

EnvDurationVar adds environment variable which is evaluate before evaluating options It is the environment counterpart to flag.DurationVar()

func (*Cli) EnvFloat64

func (c *Cli) EnvFloat64(name string, value float64, usage string) *float64

EnvFloat64 adds environment variable which is evaluate before evaluating options It is the environment counterpart to flag.Float64Var()

func (*Cli) EnvInt

func (c *Cli) EnvInt(name string, value int, usage string) *int

EnvInt adds environment variable which is evaluate before evaluating options It is the environment counterpart to flag.IntVar()

func (*Cli) EnvInt64

func (c *Cli) EnvInt64(name string, value int64, usage string) *int64

EnvInt64 adds environment variable which is evaluate before evaluating options It is the environment counterpart to flag.Int64Var()

func (*Cli) EnvInt64Var

func (c *Cli) EnvInt64Var(p *int64, name string, value int64, usage string) error

EnvInt64Var adds environment variable which is evaluate before evaluating options It is the environment counterpart to flag.Int64Var()

func (*Cli) EnvIntVar

func (c *Cli) EnvIntVar(p *int, name string, value int, usage string) error

EnvIntVar adds environment variable which is evaluate before evaluating options It is the environment counterpart to flag.IntVar()

func (*Cli) EnvString

func (c *Cli) EnvString(name string, value string, usage string) *string

EnvString adds environment variable which is evaluate before evaluating options It is the environment counterpart to flag.StringVar()

func (*Cli) EnvStringVar

func (c *Cli) EnvStringVar(p *string, name string, value string, usage string) error

EnvStringVar adds environment variable which is evaluate before evaluating options It is the environment counterpart to flag.StringVar()

func (*Cli) EnvUint

func (c *Cli) EnvUint(name string, value uint, usage string) *uint

EnvUint adds environment variable which is evaluate before evaluating options It is the environment counterpart to flag.UintVar()

func (*Cli) EnvUint64

func (c *Cli) EnvUint64(name string, value uint64, usage string) *uint64

EnvUint64 adds environment variable which is evaluate before evaluating options It is the environment counterpart to flag.Uint64Var()

func (*Cli) EnvUint64Var

func (c *Cli) EnvUint64Var(p *uint64, name string, value uint64, usage string) error

EnvUint64Var adds environment variable which is evaluate before evaluating options It is the environment counterpart to flag.Uint64Var()

func (*Cli) EnvUintVar

func (c *Cli) EnvUintVar(p *uint, name string, value uint, usage string) error

EnvUintVar adds environment variable which is evaluate before evaluating options It is the environment counterpart to flag.UintVar()

func (*Cli) Float64Var

func (c *Cli) Float64Var(p *float64, names string, value float64, usage string)

Float64Var updates c.options doc strings, then splits options and calls flag.Float64Var()

func (*Cli) GenerateManPage added in v0.0.13

func (c *Cli) GenerateManPage(w io.Writer)

GenerateManPage writes a manual page suitable for running through `nroff --man`. May need some human clean up depending on content and internal formatting (e.g markdown style, spacing, etc.)

func (*Cli) GenerateMarkdown added in v0.0.13

func (c *Cli) GenerateMarkdown(w io.Writer)

GenerateMarkdown writes a Markdown page to io.Writer provided. Documentation is based on the application's metadata like app name, version, options, actions, etc.

func (*Cli) Getenv

func (c *Cli) Getenv(name string) string

Getenv returns a given environment attribute value as a string

func (*Cli) Help

func (c *Cli) Help(keywords ...string) string

Help returns documentation on a topic. If first looks in Documentation map and and if not there return a not documented string.

func (*Cli) Int64Var

func (c *Cli) Int64Var(p *int64, names string, value int64, usage string)

Int64Var updates c.options doc strings, then splits options and calls flag.Int64Var()

func (*Cli) IntVar

func (c *Cli) IntVar(p *int, names string, value int, usage string)

IntVar updates c.options doc strings, then splits options and calls flag.IntVar()

func (*Cli) License

func (c *Cli) License() string

func (*Cli) NArg

func (c *Cli) NArg() int

NArg returns flag.NArg()

func (*Cli) NewVerb added in v0.0.16

func (c *Cli) NewVerb(name string, usage string, fn func(io.Reader, io.Writer, io.Writer, []string, *flag.FlagSet) int) *Verb

NewVerb associates a verb, synopsis and function with a command line interface. It supercedes AddVerb(), and AddAction(). Verbs can have their own options and documentation.

func (*Cli) Option

func (c *Cli) Option(op string) string

Option returns an option's document string or unsupported string

func (*Cli) Options

func (c *Cli) Options() map[string]string

Options returns a map of option values and doc strings

func (*Cli) Parse

func (c *Cli) Parse() error

Parse process both the environment and any flags

func (*Cli) ParseEnv

func (c *Cli) ParseEnv() error

ParseEnv loops through the os environment using os.Getenv() and updates c.env EnvAttribute. Returns an error if there is a problem with environment.

func (*Cli) ParseOptions

func (c *Cli) ParseOptions()

ParseOptions envokes flag.Parse() updating variables set in AddOptions

func (*Cli) Run

func (c *Cli) Run(args []string) int

(c *Cli) Run takes a list of non-option arguments and runs them if the fist arg (i.e. arg[0] has a corresponding action. Returns an int suitable to passing to os.Exit()

func (*Cli) SetParams added in v0.0.16

func (c *Cli) SetParams(params ...string)

Set Params generates explicit documentation for expected parameters instead of using those defined by verbs and actions.

func (*Cli) StringVar

func (c *Cli) StringVar(p *string, names string, value string, usage string)

StringVar updates c.options doc strings, then splits options and calls flag.StringVar()

func (*Cli) Uint64Var

func (c *Cli) Uint64Var(p *uint64, names string, value uint64, usage string)

Uint64Var updates c.options doc strings, then splits options and calls flag.Int64Var()

func (*Cli) UintVar

func (c *Cli) UintVar(p *uint, names string, value uint, usage string)

UintVar updates c.options doc strings, then splits options and calls flag.Int64Var()

func (*Cli) Usage

func (c *Cli) Usage(w io.Writer)

Usage writes a help page to io.Writer provided. Documentation is based on the application's metadata like app name, version, options, actions, etc.

func (*Cli) Verb added in v0.0.13

func (c *Cli) Verb(args []string) string

Verb returns the verb in an arg list without poping the verb. If arg list is empty then an empty string is returned.

func (*Cli) Verbs added in v0.0.16

func (c *Cli) Verbs() map[string]string

Verbs returns a map of verbs and their doc strings

func (*Cli) Version

func (c *Cli) Version() string

type EnvAttribute

type EnvAttribute struct {
	// Name is the environment variable (e.g. DATASET, USERNAME)
	Name string
	// Type holds the type name of the attribute, e.g. int, int64, float64, string, bool, uint, uint64, time.Duration
	Type string
	// BoolValue holds the default boolean
	BoolValue bool
	// IntValue holds the default int
	IntValue int
	// Int64Value holds the default int64
	Int64Value int64
	// UintValue holds the default uint
	UintValue uint
	// Uint64Value holds the default uint64
	Uint64Value uint64
	// Float64Value holds the default float64
	Float64Value float64
	// Dura1tionValue holds the default time.Duration
	DurationValue time.Duration
	// StringValue holds the default string
	StringValue string
	// Usage describes the environment variable role and expected setting
	Usage string
}

EnvAttribute describes expected environmental attributes associated with the cli app. It also provides the default value of the environmental attribute if missing from the environment.

type Verb added in v0.0.16

type Verb struct {
	// Name of the verb
	Name string

	// Usage, a one line description
	Usage string

	// Documentation is a map to help documentation (usually detailed)
	Documentation map[string][]byte

	// SectionNo corresponds to the manual section number (used in generating man pages)
	SectionNo int

	// Fn holds the main function associated with the verb, often is passed
	// stdin, stdout and stnerror returns a value suitable for passing to
	// os.Exit()
	Fn func(io.Reader, io.Writer, io.Writer, []string, *flag.FlagSet) int

	// FlagSet holds the parsable options associated with the verb.
	FlagSet *flag.FlagSet
	// contains filtered or unexported fields
}

Verb holds the metadata for an keyword action associated with a cli. e.g. `go test` would have the verb "test" and the Verb struct would define options related metadata associated with that verb.

func NewVerb added in v0.0.16

func NewVerb(name, usage string, fn func(io.Reader, io.Writer, io.Writer, []string, *flag.FlagSet) int) *Verb

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.

func (*Verb) AddFlagSet added in v0.0.16

func (v *Verb) AddFlagSet(flagSet *flag.FlagSet)

AddFlagSet adds/replaces a flag set associated with verbs

func (*Verb) AddHelp added in v0.0.16

func (v *Verb) AddHelp(keyword string, usage []byte) error

AddHelp takes a string keyword and byte slice of content and updates the Documentation attribute

func (*Verb) Arg added in v0.0.16

func (v *Verb) Arg(i int) string

Arg returns an argument by pos index

func (*Verb) Args added in v0.0.16

func (v *Verb) Args() []string

Args returns v.FlagSet.Args()

func (*Verb) BoolVar added in v0.0.16

func (v *Verb) BoolVar(p *bool, names string, value bool, usage string)

BoolVar updates v.options doc strings, then splits options and calls v.FlagSet.BoolVar()

func (*Verb) DurationVar added in v0.0.16

func (v *Verb) DurationVar(p *time.Duration, names string, value time.Duration, usage string)

DurationVar updates v.options doc strings, then splits options and calls v.FlagSet.DurationVar()

func (*Verb) Float64Var added in v0.0.16

func (v *Verb) Float64Var(p *float64, names string, value float64, usage string)

Float64Var updates v.options doc strings, then splits options and calls v.FlagSet.Float64Var()

func (*Verb) HasOptions added in v0.0.16

func (v *Verb) HasOptions() bool

HasOptions returns true if len(v.options) > 0, false otherwise

func (*Verb) Help added in v0.0.16

func (v *Verb) Help(keywords ...string) string

Help returns documentation on a topic. If first looks in Documentation map and if nothing found looks in Synopsis map and if not there return an empty string not documented string.

func (*Verb) Int64Var added in v0.0.16

func (v *Verb) Int64Var(p *int64, names string, value int64, usage string)

Int64Var updates v.options doc strings, then splits options and calls v.FlagSet.Int64Var()

func (*Verb) IntVar added in v0.0.16

func (v *Verb) IntVar(p *int, names string, value int, usage string)

IntVar updates v.options doc strings, then splits options and calls v.FlagSet.IntVar()

func (*Verb) NArg added in v0.0.16

func (v *Verb) NArg() int

NArg returns v.FlagSet.NArg()

func (*Verb) Option added in v0.0.16

func (v *Verb) Option(op string) string

Option returns an option's document string or unsupported string

func (*Verb) Options added in v0.0.16

func (v *Verb) Options() map[string]string

Options returns a map of option values and doc strings

func (*Verb) Parse added in v0.0.16

func (v *Verb) Parse(args []string) error

Parse envokes v.FlagSet.Parse() updating variables set in AddOptions

func (*Verb) SetParams added in v0.0.16

func (v *Verb) SetParams(params ...string)

SetParams documents any parameters not defined as Options, it is an orders list of strings

func (*Verb) String added in v0.0.16

func (v *Verb) String() string

String prints an actions' verb and description

func (*Verb) StringVar added in v0.0.16

func (v *Verb) StringVar(p *string, names string, value string, usage string)

StringVar updates v.options doc strings, then splits options and calls v.FlagSet.StringVar()

func (*Verb) Uint64Var added in v0.0.16

func (v *Verb) Uint64Var(p *uint64, names string, value uint64, usage string)

Uint64Var updates v.options doc strings, then splits options and calls v.FlagSet.Int64Var()

func (*Verb) UintVar added in v0.0.16

func (v *Verb) UintVar(p *uint, names string, value uint, usage string)

UintVar updates v.options doc strings, then splits options and calls v.FlagSet.Int64Var()

Directories

Path Synopsis
cmd
cligenerate
cligenerate is a cli application generator, e.g.
cligenerate is a cli application generator, e.g.
pkgassets is a command line tool for harvesting directory contents (like website default files) and turning them into a Go package with a map of path and byte array of contents harvested.
pkgassets is a command line tool for harvesting directory contents (like website default files) and turning them into a Go package with a map of path and byte array of contents harvested.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL