Documentation
¶
Index ¶
- Constants
- Variables
- func IsAdmin() bool
- func OnUnix() bool
- func OnWindows() bool
- func ValidateName(name string) (err error)
- type App
- func (c *App) Complete(args []string, partial string) (suggestions []string, finished bool, err error)
- func (a *App) FS() fs.FS
- func (a *App) GlobalConfigFile() path.Relative
- func (a *App) Load(checkmissing bool) (err error)
- func (a *App) LocalConfigFile() path.Relative
- func (a *App) Name() string
- func (a *App) Reset()
- func (a *App) Run() (err error)
- func (a *App) RunAndExit()
- func (a *App) SelectedCommand() *Command
- func (a *App) Stderr() io.Writer
- func (a *App) Stdin() io.Reader
- func (a *App) Stdout() io.Writer
- func (p *App) Usage() string
- func (a *App) UserConfigFile() path.Relative
- func (a *App) Version() string
- func (a *App) WithArgs(args []string) *App
- func (a *App) WithAsciiArt() *App
- func (a *App) WithDescription(descr string) *App
- func (a *App) WithEnv(env []string) *App
- func (a *App) WithFS(fsys fs.FS) *App
- func (a *App) WithStdErr(wr io.Writer) *App
- func (a *App) WithStdOut(wr io.Writer) *App
- func (a *App) WithStdin(rd io.Reader, viaPipe bool) *App
- func (a *App) WithVersion(maj, min, patch int) *App
- type Application
- type Arg
- type BashComplete
- type Bool
- type Byte
- type Command
- func (c *Command) AddArg(name string, val Value) *Arg
- func (c *Command) AddCommand(name string, callback func(Application) error) *Command
- func (c *Command) AddFlag(name string, val Value) *Flag
- func (c *Command) AddStdinArg(name string, val Value) *Arg
- func (c *Command) AddStdinFlag(name string, val Value) *Flag
- func (c *Command) AllArgs(target *[]string)
- func (c *Command) Help() string
- func (c *Command) Name() string
- func (c *Command) NeedsSubCommand() *Command
- func (c *Command) Relax(flags ...*Flag) *Command
- func (c *Command) Require(flags ...*Flag) *Command
- func (c *Command) Run() error
- func (c *Command) Skip(flags ...*Flag) *Command
- func (c *Command) SkipAllBut(except ...*Flag) *Command
- func (c *Command) Usage() string
- func (c *Command) WithHelp(help string) *Command
- func (c *Command) WithHideFromHelp() *Command
- func (c *Command) WithStdinHandler(stdinHandler func(io.Reader) error) *Command
- type Date
- type DateTime
- type DirLocal
- func (v *DirLocal) Complete(prefix string) (suggestions []string, finished bool, err error)
- func (f *DirLocal) DoesComplete() bool
- func (v DirLocal) IsBool() bool
- func (f *DirLocal) IsDir() bool
- func (f *DirLocal) IsPath() bool
- func (v DirLocal) IsSlice() bool
- func (f *DirLocal) Matcher() *regexp.Regexp
- func (v *DirLocal) New() Value
- func (f *DirLocal) Set(s string) (err error)
- func (v *DirLocal) SetName(name string)
- func (f DirLocal) Type() string
- func (v *DirLocal) Unset()
- type DirRO
- func (v *DirRO) Complete(prefix string) (suggestions []string, finished bool, err error)
- func (v *DirRO) DoesComplete() bool
- func (v DirRO) IsBool() bool
- func (v DirRO) IsSlice() bool
- func (f *DirRO) New() Value
- func (f *DirRO) Set(s string) (err error)
- func (v *DirRO) SetName(name string)
- func (DirRO) Type() string
- func (v *DirRO) Unset()
- type DirRW
- func (v *DirRW) Complete(prefix string) (suggestions []string, finished bool, err error)
- func (v *DirRW) DoesComplete() bool
- func (v DirRW) IsBool() bool
- func (v DirRW) IsSlice() bool
- func (f *DirRW) New() Value
- func (f *DirRW) Set(s string) (err error)
- func (v *DirRW) SetName(name string)
- func (DirRW) Type() string
- func (v *DirRW) Unset()
- type DirRWD
- func (v *DirRWD) Complete(prefix string) (suggestions []string, finished bool, err error)
- func (v *DirRWD) DoesComplete() bool
- func (v DirRWD) IsBool() bool
- func (v DirRWD) IsSlice() bool
- func (f *DirRWD) New() Value
- func (f *DirRWD) Set(s string) (err error)
- func (v *DirRWD) SetName(name string)
- func (DirRWD) Type() string
- func (v *DirRWD) Unset()
- type DirT
- func (v *DirT) Complete(prefix string) (suggestions []string, finished bool, err error)
- func (v *DirT) DoesComplete() bool
- func (v DirT) IsBool() bool
- func (v DirT) IsSlice() bool
- func (f *DirT[T]) New() Value
- func (f *DirT[T]) Set(s string) (err error)
- func (v *DirT) SetName(name string)
- func (DirT[T]) Type() string
- func (v *DirT) Unset()
- type FSGroupRO
- type FSGroupRW
- type FSGroupRWD
- type FileLocal
- func (v *FileLocal) Complete(prefix string) (suggestions []string, finished bool, err error)
- func (f *FileLocal) DoesComplete() bool
- func (v FileLocal) IsBool() bool
- func (f *FileLocal) IsDir() bool
- func (f *FileLocal) IsPath() bool
- func (v FileLocal) IsSlice() bool
- func (f *FileLocal) Matcher() *regexp.Regexp
- func (v *FileLocal) New() Value
- func (f *FileLocal) Set(s string) (err error)
- func (v *FileLocal) SetName(name string)
- func (f FileLocal) Type() string
- func (v *FileLocal) Unset()
- type FileRO
- func (v *FileRO) Complete(prefix string) (suggestions []string, finished bool, err error)
- func (v *FileRO) DoesComplete() bool
- func (v FileRO) IsBool() bool
- func (v FileRO) IsSlice() bool
- func (f *FileRO) New() Value
- func (f *FileRO) Set(s string) (err error)
- func (v *FileRO) SetName(name string)
- func (FileRO) Type() string
- func (v *FileRO) Unset()
- type FileRW
- func (v *FileRW) Complete(prefix string) (suggestions []string, finished bool, err error)
- func (v *FileRW) DoesComplete() bool
- func (v FileRW) IsBool() bool
- func (v FileRW) IsSlice() bool
- func (f *FileRW) New() Value
- func (f *FileRW) Set(s string) (err error)
- func (v *FileRW) SetName(name string)
- func (FileRW) Type() string
- func (v *FileRW) Unset()
- type FileRWD
- func (v *FileRWD) Complete(prefix string) (suggestions []string, finished bool, err error)
- func (v *FileRWD) DoesComplete() bool
- func (v FileRWD) IsBool() bool
- func (v FileRWD) IsSlice() bool
- func (f *FileRWD) New() Value
- func (f *FileRWD) Set(s string) (err error)
- func (v *FileRWD) SetName(name string)
- func (FileRWD) Type() string
- func (v *FileRWD) Unset()
- type FileT
- func (v *FileT) Complete(prefix string) (suggestions []string, finished bool, err error)
- func (v *FileT) DoesComplete() bool
- func (v FileT) IsBool() bool
- func (v FileT) IsSlice() bool
- func (f *FileT[T]) New() Value
- func (v *FileT) SetName(name string)
- func (FileT[T]) Type() string
- func (v *FileT) Unset()
- type Flag
- type Float32
- type Float64
- type Int
- type InvalidNameError
- type InvalidSelection
- type JSON
- func (v *JSON) Complete(prefix string) (suggestions []string, finished bool, err error)
- func (v *JSON) DoesComplete() bool
- func (v JSON) IsBool() bool
- func (v JSON) IsSlice() bool
- func (m *JSON[T]) New() Value
- func (m *JSON[T]) Set(s string) (err error)
- func (v *JSON) SetName(name string)
- func (m JSON[T]) Type() string
- func (v *JSON) Unset()
- type Map
- func (v *Map) Complete(prefix string) (suggestions []string, finished bool, err error)
- func (v *Map) DoesComplete() bool
- func (v Map) IsBool() bool
- func (v Map) IsSlice() bool
- func (v *Map) New() Value
- func (m *Map) Set(s string) (err error)
- func (v *Map) SetName(name string)
- func (m Map) Type() string
- func (v *Map) Unset()
- type PathT
- func (v *PathT) Complete(prefix string) (suggestions []string, finished bool, err error)
- func (v *PathT) DoesComplete() bool
- func (v PathT) IsBool() bool
- func (v PathT) IsSlice() bool
- func (f *PathT[T]) New() Value
- func (f *PathT[T]) Set(s string) (err error)
- func (v *PathT) SetName(name string)
- func (v *PathT) Unset()
- type STDIN
- type Select
- func (m Select[T]) Complete(prefix string) (suggestions []string, finished bool, err error)
- func (m Select[T]) DoesComplete() bool
- func (m *Select[T]) IsBool() bool
- func (v Select) IsSlice() bool
- func (m *Select[T]) New() Value
- func (m *Select[T]) Set(s string) (err error)
- func (v *Select) SetName(name string)
- func (m Select[T]) Type() string
- func (v *Select) Unset()
- type SelectFunc
- func (m *SelectFunc[T]) Complete(prefix string) (suggestions []string, finished bool, err error)
- func (m *SelectFunc[T]) DoesComplete() bool
- func (m *SelectFunc[T]) IsBool() bool
- func (v SelectFunc) IsSlice() bool
- func (m *SelectFunc[T]) New() Value
- func (m *SelectFunc[T]) Set(s string) (err error)
- func (v *SelectFunc) SetName(name string)
- func (m *SelectFunc[T]) Type() string
- func (v *SelectFunc) Unset()
- type Slice
- func (v *Slice) Complete(prefix string) (suggestions []string, finished bool, err error)
- func (v *Slice) DoesComplete() bool
- func (m Slice[P]) IsBool() bool
- func (m Slice[P]) IsSlice() bool
- func (v *Slice) New() Value
- func (m *Slice[P]) Set(s string) (err error)
- func (v *Slice) SetName(name string)
- func (m *Slice[P]) String() string
- func (m Slice[P]) Type() string
- func (v *Slice) Unset()
- type String
- type Time
- type TimeFormat
- type URL
- func (v *URL) Complete(prefix string) (suggestions []string, finished bool, err error)
- func (v *URL) DoesComplete() bool
- func (v URL) IsBool() bool
- func (v URL) IsSlice() bool
- func (v *URL) New() Value
- func (m *URL) Set(s string) (err error)
- func (v *URL) SetName(name string)
- func (m URL) Type() string
- func (v *URL) Unset()
- type Uint
- type Value
Constants ¶
const ( MaxLenFlagName = 18 MaxLenArgName = 18 MaxLenCommandName = 20 MaxLenAppName = 30 )
Variables ¶
var ErrInterrupt = fmt.Errorf("pseudo error to interrupt processing, e.g. for help command")
var VERSION version.Version
Functions ¶
func ValidateName ¶
Types ¶
type App ¶
type App struct { *Command // contains filtered or unexported fields }
func (*App) GlobalConfigFile ¶
func (*App) LocalConfigFile ¶
func (*App) RunAndExit ¶ added in v3.0.21
func (a *App) RunAndExit()
func (*App) SelectedCommand ¶ added in v3.0.8
func (*App) UserConfigFile ¶
func (*App) WithAsciiArt ¶
func (*App) WithDescription ¶
func (*App) WithVersion ¶
type Application ¶
type Arg ¶
type Arg struct {
// contains filtered or unexported fields
}
argument is a parameter that has no flag but is scanned based on the position
func (*Arg) IsRequired ¶
func (*Arg) WithDefault ¶
func (*Arg) WithRequired ¶
type BashComplete ¶ added in v3.0.4
type BashComplete struct { IncludeFile path.Relative // the filepath (relative to the FS) where the bash script is located that should be included in the .bashrc FS fs.FS // the filesystem that deals with the include file Completer bash_completion.Completer // the completer has the complete method that is called by the bash completion, when the user presses <tab> ProgramName string // name of the program (file name) EnvVar string // the environmental variable that should be set and checked to determine, if completion is activated Command *Command // the command inside the CLI app,beneath which the complete command will reside (the command that is called from the bash voia the include file) OnBeforeComplete func() error // is called on complete before the bash_completion.Completer Complete method is called // contains filtered or unexported fields }
func (*BashComplete) Setup ¶ added in v3.0.4
func (r *BashComplete) Setup()
type Command ¶
type Command struct {
// contains filtered or unexported fields
}
if the name is "", this is the main command
func (*Command) AddCommand ¶
func (c *Command) AddCommand(name string, callback func(Application) error) *Command
func (*Command) NeedsSubCommand ¶
func (*Command) SkipAllBut ¶
func (*Command) WithHideFromHelp ¶ added in v3.0.7
type DirLocal ¶ added in v3.0.9
type DirLocal struct { Val path.Local RegExp *regexp.Regexp // contains filtered or unexported fields }
func (*DirLocal) DoesComplete ¶ added in v3.0.20
type DirRO ¶
type DirRO struct {
FileRO
}
func NewDirRO ¶
NewDirRO returns a Dir that is readonly. The given filesystems must all implement fs.ExtURLInit and fs.ReadOnly
func (*DirRO) DoesComplete ¶ added in v3.0.25
func (v *DirRO) DoesComplete() bool
type DirRW ¶
type DirRW struct {
FileRW
}
func NewDirRW ¶
NewDirRW returns a Dir that is readable and writeable. The given filesystems must all implement FSReadWrite
func (*DirRW) DoesComplete ¶ added in v3.0.25
func (v *DirRW) DoesComplete() bool
type DirRWD ¶
type DirRWD struct {
FileRWD
}
func NewDirRWD ¶
func NewDirRWD(fsyses ...FSGroupRWD) *DirRWD
NewDirRWD returns a Dir that is readable, writeable and deletable. The given filesystems must all implement FSReadWriteDelete
func (*DirRWD) DoesComplete ¶ added in v3.0.25
func (v *DirRWD) DoesComplete() bool
type DirT ¶
func NewDirT ¶
func NewDirT[T fs.ReadOnly](fsyses ...fs.ExtGroupable[T]) *DirT[T]
NewDirT returns a Dir given on the based Type T that at least implements fs.ReadOnly, but might be whatever FS interface on top. The given filesystems must all implement fs.ExtURLInit and the given interface type T
func (*DirT) DoesComplete ¶ added in v3.0.25
func (v *DirT) DoesComplete() bool
type FSGroupRO ¶
type FSGroupRO = fs.ExtGroupable[fs.ReadOnly]
func FSReadonly ¶
func FSReadonly() []FSGroupRO
func LocalFSReadonly ¶
func LocalFSReadonly() []FSGroupRO
type FSGroupRW ¶
type FSGroupRW = fs.ExtGroupable[fs.ExtWriteable]
func LocalFS_RW ¶
func LocalFS_RW() []FSGroupRW
type FSGroupRWD ¶
type FSGroupRWD = fs.ExtGroupable[fs.FS]
func LocalFS ¶
func LocalFS() []FSGroupRWD
type FileLocal ¶ added in v3.0.9
type FileLocal struct { Val path.Local RegExp *regexp.Regexp // contains filtered or unexported fields }
func (*FileLocal) DoesComplete ¶ added in v3.0.20
type FileRO ¶
type FileRO struct { fs.PathT[fs.ReadOnly] Group *fs.Group[fs.ReadOnly] // contains filtered or unexported fields }
func NewFileRO ¶
NewFileRO returns a File that is readonly. The given filesystems must all implement fs.ExtGroupable and fs.ReadOnly
func (*FileRO) DoesComplete ¶ added in v3.0.25
func (v *FileRO) DoesComplete() bool
type FileRW ¶
type FileRW struct { fs.PathRW[fs.ExtWriteable] Group *fs.Group[fs.ExtWriteable] // contains filtered or unexported fields }
func NewFileRW ¶
NewFileRW returns a File that is readable and writeable. The given filesystems must all implement fs.ExtGroupable and fs.ExtWriteable
func (*FileRW) DoesComplete ¶ added in v3.0.25
func (v *FileRW) DoesComplete() bool
type FileRWD ¶
func NewFileRWD ¶
func NewFileRWD(fsyses ...FSGroupRWD) *FileRWD
NewFileRWD returns a File that is readable, writeable and deletable. The given filesystems must all implement fs.ExtGroupable and fs.FS
func (*FileRWD) DoesComplete ¶ added in v3.0.25
func (v *FileRWD) DoesComplete() bool
type FileT ¶
func NewFileT ¶
func NewFileT[T fs.ReadOnly](fsyses ...fs.ExtGroupable[T]) *FileT[T]
NewFileT returns a File given on the based Type T that at least implements fs.ReadOnly, but might be whatever FS interface on top. The given filesystems must all implement fs.ExtGroupable and the given interface type T
func (*FileT) DoesComplete ¶ added in v3.0.25
func (v *FileT) DoesComplete() bool
type Flag ¶
type Flag struct { Arg // contains filtered or unexported fields }
flag has -- prefix when called, or - for shortflag
func (*Flag) WithDefault ¶
func (*Flag) WithRequired ¶
func (*Flag) WithShortFlag ¶
type InvalidNameError ¶
type InvalidNameError string
func (InvalidNameError) Error ¶
func (e InvalidNameError) Error() string
type InvalidSelection ¶
func (InvalidSelection) Error ¶
func (e InvalidSelection) Error() string
type JSON ¶
type JSON[T any] struct { Val T // contains filtered or unexported fields }
func (*JSON) DoesComplete ¶ added in v3.0.25
func (v *JSON) DoesComplete() bool
type Map ¶
func (*Map) DoesComplete ¶ added in v3.0.25
func (v *Map) DoesComplete() bool
type PathT ¶
type PathT[T fs.ReadOnly] struct { fs.PathT[T] Group *fs.Group[T] // contains filtered or unexported fields }
func (*PathT) DoesComplete ¶ added in v3.0.25
func (v *PathT) DoesComplete() bool
type Select ¶
type Select[T value.StrConverteable] struct { //Var[string] Options []string OtherAllowed bool // contains filtered or unexported fields }
func NewSelect ¶ added in v3.0.2
func NewSelect[T value.StrConverteable](options ...string) Select[T]
func NewSelectWithNew ¶ added in v3.0.2
func NewSelectWithNew[T value.StrConverteable](options ...string) Select[T]
func (Select[T]) DoesComplete ¶ added in v3.0.20
type SelectFunc ¶
type SelectFunc[T value.StrConverteable] struct { OtherAllowed bool // contains filtered or unexported fields }
func NewSelectFunc ¶
func NewSelectFunc[T value.StrConverteable](fn func() []string) SelectFunc[T]
func (*SelectFunc[T]) Complete ¶ added in v3.0.20
func (m *SelectFunc[T]) Complete(prefix string) (suggestions []string, finished bool, err error)
func (*SelectFunc[T]) DoesComplete ¶ added in v3.0.20
func (m *SelectFunc[T]) DoesComplete() bool
func (*SelectFunc[T]) IsBool ¶
func (m *SelectFunc[T]) IsBool() bool
func (*SelectFunc[T]) New ¶
func (m *SelectFunc[T]) New() Value
func (*SelectFunc[T]) Set ¶
func (m *SelectFunc[T]) Set(s string) (err error)
func (*SelectFunc[T]) Type ¶
func (m *SelectFunc[T]) Type() string
type Slice ¶
type Slice[P Value] struct { Vals []P // contains filtered or unexported fields }
func (*Slice) DoesComplete ¶ added in v3.0.25
func (v *Slice) DoesComplete() bool
type TimeFormat ¶
type TimeFormat struct { Format string // contains filtered or unexported fields }
func NewTimeFormat ¶
func NewTimeFormat(format string) TimeFormat
func (*TimeFormat) New ¶
func (m *TimeFormat) New() Value
func (*TimeFormat) Set ¶
func (m *TimeFormat) Set(s string) error
func (*TimeFormat) Type ¶
func (m *TimeFormat) Type() string
type URL ¶
func (*URL) DoesComplete ¶ added in v3.0.25
func (v *URL) DoesComplete() bool
Source Files
¶
- app.go
- arg.go
- args.go
- cmd_bash_completion.go
- cmd_config.go
- cmd_help.go
- cmd_version.go
- command.go
- complete_app.go
- complete_bash.go
- complete_path.go
- config.go
- env.go
- file.go
- flag.go
- fs.go
- helper.go
- run.go
- type_dir.go
- type_file.go
- type_json.go
- type_map.go
- type_other.go
- type_select.go
- type_selectfunc.go
- type_slice.go
- type_timeformat.go
- type_url.go
- type_var.go
- validation.go
- value.go
- version.go