cmdflag

Imports

Imports #

"errors"
"flag"
"fmt"
"strings"

Constants & Variables

ErrFlagTerminator var #

ErrFlagTerminator indicates the distinguished token "--", which causes the flag package to treat all subsequent arguments as non-flags.

var ErrFlagTerminator = *ast.CallExpr

Interfaces

boolFlag interface #

type boolFlag interface {
IsBoolFlag() bool
}

Structs

FlagNotDefinedError struct #

A FlagNotDefinedError indicates a flag-like argument that does not correspond to any registered flag in a FlagSet.

type FlagNotDefinedError struct {
RawArg string
Name string
HasValue bool
Value string
}

NonFlagError struct #

A NonFlagError indicates an argument that is not a syntactically-valid flag.

type NonFlagError struct {
RawArg string
}

Functions

Error method #

func (e FlagNotDefinedError) Error() string

Error method #

func (e NonFlagError) Error() string

ParseOne function #

ParseOne sees if args[0] is present in the given flag set and if so, sets its value and returns the flag along with the remaining (unused) arguments. ParseOne always returns either a non-nil Flag or a non-nil error, and always consumes at least one argument (even on error). Unlike (*flag.FlagSet).Parse, ParseOne does not log its own errors.

func ParseOne(fs *flag.FlagSet, args []string) (f *flag.Flag, remainingArgs []string, err error)

Generated with Arrow