Clive, 2nd ed. User's manual. Section 2

import "clive/cmd/opt"

const TimeFormat = "2006/0102 15:04"
func ParseTime(arg string) (time.Time, error)
func New(usage string) *Flags
func ParseRange(arg string) (Range, error)
type Counter int
type Flags struct { ... }
    func New(usage string) *Flags
type Hexa int
type Octal int
type Range struct { ... }
    func ParseRange(arg string) (Range, error)


command line options, in the unix style and working on any argv[] array.

The functions that define new flags operate in the same way: They define a
new flag and, if a pointer is given, the value pointed to is set when the
flag is present in the command line. They call Fatal if a flag is defined

Flags should be defined by the same process, there is no mutex.


const TimeFormat = "2006/0102 15:04"
    Preferred default time format for commands.


type Counter int
    Use Counter as the value for counting flags, which are bool flags that can
    be repeated. Their value is the number of repetitions.

type Flags struct {
	Argv0 string // program name from the last call to Parse
	// contains filtered or unexported fields
    A set of command line options

func New(usage string) *Flags
    Create a new set of command line options. Default values are to be set by
    the caller before processing the options. The functions define new flags
    and, if a pointer is given, it is set to the option value when the option is
    set in the command line.

func (f *Flags) AddUsage(xtra string)

func (f *Flags) NewFlag(name, help string, vp interface{})
    Define a new flag with the given name and usage. valuep must be a pointer to
    the argument type and will be set to the command line flag value if the flag
    is found. Known types are bool, int, Counter, Octal, Hexa, int64, uint64,
    string, float64, time.Duration, time.Time, and []string. []string is a
    string option that may be repeated. The time formats understood are

    "01/02 15:04"
    "01/02/06 15:04"
    "01/02/2006 15:04"
    "2006/0102 15:04 "

    If the name is "+..." or "-..." and vp is *int, then it is understood as a
    request to accept +number or -number as an argument.

    The help string should just describe the flag for flags with no argument,
    and should be something like "dir: do this with dir" if the flag accepts a
    "dir" argument. This convention is used to generate a good usage diagnostic.

func (f *Flags) Parse(argv ...string) []string
    Parse argv for the the flags and return the resulting argument vector w/o
    flags. The first entry in argv is the program name. A "--" argument
    terminates the options. A "-?" argument fails with a "usage" error If argv
    is nil, it is taken from the current cmd context. An error in parsing calls
    Usage() and terminates execution.

func (f *Flags) Usage()
    Print to stderr a description of the usage and exit.

type Hexa int
    Use Hexa as the value for an int flag expressed in hexa.

type Octal int
    Use Octal as the value for an int flag expressed in octal.

type Range struct {
	P0, P1 int
    A range: items are counted starting from 1 and neg. values are used to count
    backwards from the end: 1,1 means everything.

func ParseRange(arg string) (Range, error)
    Parse a range: "n," means "n,-1" (-1 indicates "last thing counting from the
    end backwards"); in "a,b", a defaults to 1 and b defaults to -1 (-1 means

func (a Range) Matches(i, n int) bool
    True when the range matches the i-th item out of n items (n may be 0 if we
    don't know the number of items). Provided here so the range semantics are
    preserved in commands.

func (r Range) String() string


func ParseTime(arg string) (time.Time, error)

User's manual, 2nd ed. Section 2