Versions in this module Expand all Collapse all v0 v0.16.0 Dec 20, 2024 v0.15.1 Dec 16, 2024 v0.15.0 Dec 16, 2024 v0.14.0 Nov 29, 2024 v0.13.0 Nov 22, 2024 Changes in this version + var W = func(s string) string + func ApplyDefaults(target any, options ...Option) error + func BindW(w func(s string) string) + func DefaultHelpPrinter(options HelpOptions, ctx *Context) error + func DefaultHelpValueFormatter(value *Value) string + func DefaultShortHelpPrinter(options HelpOptions, ctx *Context) error + func ExpandPath(path string) string + func HasInterpolatedVar(s string, v string) bool + func JoinEscaped(s []string, sep rune) string + func LineIndenter(prefix string) string + func SpaceIndenter(prefix string) string + func SplitEscaped(s string, sep rune) (out []string) + func ToText(w io.Writer, text string, prefix, codePrefix string, width int) + func TreeIndenter(prefix string) string + func Visit(node Visitable, visitor Visitor) error + type AfterApply interface + AfterApply func(args ...any) error + type Application struct + HelpFlag *Flag + type Argument = Node + type BeforeApply interface + BeforeApply func(args ...any) error + type BeforeResolve interface + BeforeResolve func(args ...any) error + type BoolMapper interface + IsBool func() bool + type BoolMapperExt interface + IsBoolFromValue func(v reflect.Value) bool + type BoolMapperValue interface + IsBool func() bool + type ChangeDirFlag string + func (c ChangeDirFlag) Decode(ctx *DecodeContext) error + type Command = Node + type ConfigFlag string + func (c ConfigFlag) BeforeResolve(kong *Kong, ctx *Context, trace *Path) error + type ConfigurationLoader func(r io.Reader) (Resolver, error) + type Context struct + Args []string + Error error + Path []*Path + func Parse(cli any, options ...Option) *Context + func Trace(k *Kong, args []string) (*Context, error) + func (c *Context) AddResolver(resolver Resolver) + func (c *Context) Apply() (string, error) + func (c *Context) ApplyDefaults() error + func (c *Context) Bind(args ...any) + func (c *Context) BindTo(impl, iface any) + func (c *Context) BindToProvider(provider any) error + func (c *Context) Call(fn any, binds ...any) (out []any, err error) + func (c *Context) Command() string + func (c *Context) Empty() bool + func (c *Context) FlagValue(flag *Flag) any + func (c *Context) Flags() (flags []*Flag) + func (c *Context) PrintUsage(summary bool) error + func (c *Context) Reset() error + func (c *Context) Resolve() error + func (c *Context) Run(binds ...any) (err error) + func (c *Context) RunNode(node *Node, binds ...any) (err error) + func (c *Context) Selected() *Node + func (c *Context) Validate() error + func (c *Context) Value(path *Path) reflect.Value + type DecodeContext struct + Scan *Scanner + Value *Value + func (r *DecodeContext) WithScanner(scan *Scanner) *DecodeContext + type FileContentFlag []byte + func (f *FileContentFlag) Decode(ctx *DecodeContext) error + type Flag struct + Aliases []string + And []string + Envs []string + Group *Group + Hidden bool + Negated bool + PlaceHolder string + Short rune + Xor []string + func (f *Flag) FormatPlaceHolder() string + func (f *Flag) String() string + type Group struct + Description string + Key string + Title string + type Groups map[string]string + func (g Groups) Apply(k *Kong) error + type HelpIndenter func(prefix string) string + type HelpOptions struct + Compact bool + FlagsLast bool + Indenter HelpIndenter + NoAppSummary bool + NoExpandSubcommands bool + Summary bool + Tree bool + WrapUpperBound int + func (h *HelpOptions) CommandTree(node *Node, prefix string) (rows [][2]string) + func (h HelpOptions) Apply(k *Kong) error + type HelpPrinter func(options HelpOptions, ctx *Context) error + type HelpProvider interface + Help func() string + type HelpValueFormatter func(value *Value) string + type Kong struct + Exit func(int) + Model *Application + Stderr io.Writer + Stdout io.Writer + func Must(ast any, options ...Option) *Kong + func New(grammar any, options ...Option) (*Kong, error) + func (k *Kong) Errorf(format string, args ...any) *Kong + func (k *Kong) FatalIfErrorf(err error, args ...any) + func (k *Kong) Fatalf(format string, args ...any) + func (k *Kong) LoadConfig(path string) (Resolver, error) + func (k *Kong) Parse(args []string) (ctx *Context, err error) + func (k *Kong) Printf(format string, args ...any) *Kong + type Mapper interface + Decode func(ctx *DecodeContext, target reflect.Value) error + type MapperFunc func(ctx *DecodeContext, target reflect.Value) error + func (m MapperFunc) Decode(ctx *DecodeContext, target reflect.Value) error + type MapperValue interface + Decode func(ctx *DecodeContext) error + type NamedFileContentFlag struct + Contents []byte + Filename string + func (f *NamedFileContentFlag) Decode(ctx *DecodeContext) error + type Next func(err error) error + type Node struct + Active bool + Aliases []string + Argument *Value + Children []*Node + DefaultCmd *Node + Detail string + Flags []*Flag + Group *Group + Help string + Hidden bool + Name string + Parent *Node + Passthrough bool + Positional []*Positional + Tag *Tag + Target reflect.Value + Type NodeType + func (n *Node) AllFlags(hide bool) (out [][]*Flag) + func (n *Node) ClosestGroup() *Group + func (n *Node) Depth() int + func (n *Node) Find(ptr any) *Node + func (n *Node) FlagSummary(hide bool) string + func (n *Node) FullPath() string + func (n *Node) Leaf() bool + func (n *Node) Leaves(hide bool) (out []*Node) + func (n *Node) Path() (out string) + func (n *Node) Summary() string + func (n *Node) Vars() Vars + type NodeType int + const ApplicationNode + const ArgumentNode + const CommandNode + type Option interface + Apply func(k *Kong) error + func AutoGroup(format func(parent Visitable, flag *Flag) *Group) Option + func Bind(args ...any) Option + func BindTo(impl, iface any) Option + func BindToProvider(provider any) Option + func ClearResolvers() Option + func Configuration(loader ConfigurationLoader, paths ...string) Option + func ConfigureHelp(options HelpOptions) Option + func DefaultEnvars(prefix string) Option + func Description(description string) Option + func DynamicCommand(name, help, group string, cmd any, tags ...string) Option + func Embed(strct any, tags ...string) Option + func Exit(exit func(int)) Option + func ExplicitGroups(groups []Group) Option + func FlagNamer(namer func(fieldName string) string) Option + func Help(help HelpPrinter) Option + func HelpFormatter(helpFormatter HelpValueFormatter) Option + func IgnoreFields(regexes ...string) Option + func KindMapper(kind reflect.Kind, mapper Mapper) Option + func Name(name string) Option + func NamedMapper(name string, mapper Mapper) Option + func NoDefaultHelp() Option + func PostBuild(fn func(*Kong) error) Option + func Resolvers(resolvers ...Resolver) Option + func ShortHelp(shortHelp HelpPrinter) Option + func ShortUsageOnError() Option + func TypeMapper(typ reflect.Type, mapper Mapper) Option + func UsageOnError() Option + func ValueFormatter(helpFormatter HelpValueFormatter) Option + func ValueMapper(ptr any, mapper Mapper) Option + func Writers(stdout, stderr io.Writer) Option + type OptionFunc func(k *Kong) error + func (o OptionFunc) Apply(k *Kong) error + type ParseError struct + Context *Context + func (p *ParseError) Unwrap() error + type PassthroughProvider interface + Passthrough func([]string) + type Path struct + App *Application + Argument *Argument + Command *Command + Flag *Flag + Flags []*Flag + Parent *Node + Positional *Positional + Resolved bool + func (p *Path) Node() *Node + func (p *Path) Visitable() Visitable + type PlaceHolderProvider interface + PlaceHolder func(flag *Flag) string + type Plugins []any + type Positional = Value + type Registry struct + func NewRegistry() *Registry + func (r *Registry) ForNamedType(name string, typ reflect.Type) Mapper + func (r *Registry) ForNamedValue(name string, value reflect.Value) Mapper + func (r *Registry) ForType(typ reflect.Type) Mapper + func (r *Registry) ForValue(value reflect.Value) Mapper + func (r *Registry) RegisterDefaults() *Registry + func (r *Registry) RegisterKind(kind reflect.Kind, mapper Mapper) *Registry + func (r *Registry) RegisterName(name string, mapper Mapper) *Registry + func (r *Registry) RegisterType(typ reflect.Type, mapper Mapper) *Registry + func (r *Registry) RegisterValue(ptr any, mapper Mapper) *Registry + type Resolver interface + Resolve func(context *Context, parent *Path, flag *Flag) (any, error) + Validate func(app *Application) error + func JSON(r io.Reader) (Resolver, error) + type ResolverFunc func(context *Context, parent *Path, flag *Flag) (any, error) + func (r ResolverFunc) Resolve(context *Context, parent *Path, flag *Flag) (any, error) + func (r ResolverFunc) Validate(app *Application) error + type Scanner struct + func Scan(args ...string) *Scanner + func ScanAsType(ttype TokenType, args ...string) *Scanner + func ScanFromTokens(tokens ...Token) *Scanner + func (s *Scanner) Len() int + func (s *Scanner) Peek() Token + func (s *Scanner) Pop() Token + func (s *Scanner) PopUntil(predicate func(Token) bool) (values []Token) + func (s *Scanner) PopValue(context string) (Token, error) + func (s *Scanner) PopValueInto(context string, target any) error + func (s *Scanner) PopWhile(predicate func(Token) bool) (values []Token) + func (s *Scanner) Push(arg any) *Scanner + func (s *Scanner) PushToken(token Token) *Scanner + func (s *Scanner) PushTyped(arg any, typ TokenType) *Scanner + type SummaryProvider interface + Summary func() string + type Tag struct + Aliases []string + And []string + Arg bool + Cmd bool + Default string + Embed bool + Enum string + EnvPrefix string + Envs []string + Format string + Group string + HasDefault bool + Help string + Hidden bool + Ignored bool + MapSep rune + Name string + Negatable bool + Optional bool + Passthrough bool + PlaceHolder string + Prefix string + Required bool + Sep rune + Short rune + Type string + TypeName string + Vars Vars + Xor []string + func (t *Tag) Get(k string) string + func (t *Tag) GetAll(k string) []string + func (t *Tag) GetBool(k string) (bool, error) + func (t *Tag) GetFloat(k string) (float64, error) + func (t *Tag) GetInt(k string) (int64, error) + func (t *Tag) GetRune(k string) (rune, error) + func (t *Tag) GetSep(k string, dflt rune) (rune, error) + func (t *Tag) Has(k string) bool + func (t *Tag) String() string + type Token struct + Type TokenType + Value any + func (t Token) InferredType() TokenType + func (t Token) IsEOL() bool + func (t Token) IsValue() bool + func (t Token) String() string + type TokenType int + const EOLToken + const FlagToken + const FlagValueToken + const PositionalArgumentToken + const ShortFlagTailToken + const ShortFlagToken + const UntypedToken + func (t TokenType) IsAny(types ...TokenType) bool + func (t TokenType) String() string + type Value struct + Active bool + Default string + DefaultValue reflect.Value + Enum string + Flag *Flag + Format string + HasDefault bool + Help string + Hidden bool + Mapper Mapper + Name string + OrigHelp string + Passthrough bool + Position int + Required bool + Set bool + Tag *Tag + Target reflect.Value + func (v *Value) Apply(value reflect.Value) + func (v *Value) ApplyDefault() error + func (v *Value) EnumMap() map[string]bool + func (v *Value) EnumSlice() []string + func (v *Value) IsBool() bool + func (v *Value) IsCounter() bool + func (v *Value) IsCumulative() bool + func (v *Value) IsMap() bool + func (v *Value) IsSlice() bool + func (v *Value) Parse(scan *Scanner, target reflect.Value) (err error) + func (v *Value) Reset() error + func (v *Value) ShortSummary() string + func (v *Value) Summary() string + type Vars map[string]string + func (v Vars) Apply(k *Kong) error + func (v Vars) CloneWith(vars Vars) Vars + type VarsContributor interface + Vars func(ctx *Value) Vars + type VersionFlag bool + func (v VersionFlag) BeforeReset(app *Kong, vars Vars) error + type Visitable interface + type Visitor func(node Visitable, next Next) error