Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/alecthomas/kong
/ functions
Functions
738 in github.com/alecthomas/kong
⨍
Functions
738
◇
Types & classes
229
↓ 241 callers
Method
Parse
Parse arguments into target. The return Context can be used to further inspect the parsed command-line, to format help, to find the selected command,
kong.go:323
↓ 203 callers
Function
mustNew
(t *testing.T, cli any, options ...kong.Option)
kong_test.go:17
↓ 68 callers
Function
New
New creates a new Kong parser on grammar. See the README (https://github.com/alecthomas/kong) for usage instructions.
kong.go:82
↓ 62 callers
Method
Errorf
Errorf writes a message to Kong.Stderr with the application name prefixed.
kong.go:455
↓ 61 callers
Method
Error
()
options_test.go:85
↓ 47 callers
Method
String
()
tag.go:62
↓ 38 callers
Function
Exit
Exit overrides the function used to terminate. This is useful for testing or interactive use.
options.go:51
↓ 37 callers
Function
Writers
Writers overrides the default writers. Useful for testing or interactive use.
options.go:215
↓ 22 callers
Method
Run
()
kong_test.go:860
↓ 19 callers
Function
Description
Description sets the application description.
options.go:175
↓ 18 callers
Function
Name
Name overrides the application name.
options.go:167
↓ 18 callers
Method
PopValueInto
PopValueInto pops a value token into target or returns an error. "context" is used to assist the user if the value can not be popped, eg. "expected <
scanner.go:183
↓ 18 callers
Method
Set
Set sets the value of the binding to the given value, marking it as resolved. If the binding is not a singleton, this method does nothing.
callbacks.go:52
↓ 13 callers
Method
Summary
Summary help string for the node (not including application name).
model.go:159
↓ 12 callers
Method
Run
Run executes the Run() method on the selected command, which must exist. Any passed values will be bindable to arguments of the target Run() method.
context.go:877
↓ 12 callers
Function
newEnvParser
(t *testing.T, cli any, env envMap, options ...kong.Option)
resolver_test.go:16
↓ 11 callers
Method
Pop
Pop the front token off the Scanner.
scanner.go:151
↓ 10 callers
Function
ExpandPath
ExpandPath is a helper function to expand a relative or home-relative path to an absolute path. eg. ~/.someconf -> /home/alec/.someconf
options.go:488
↓ 9 callers
Method
Command
Command returns the full command path.
context.go:303
↓ 9 callers
Function
Resolvers
Resolvers registers flag resolvers.
options.go:417
↓ 8 callers
Method
Peek
Peek at the next Token or return an EOLToken.
scanner.go:208
↓ 8 callers
Method
Print
(text string)
help.go:406
↓ 8 callers
Function
callFunction
(f reflect.Value, bindings bindings)
callbacks.go:205
↓ 8 callers
Function
panicsTrue
(t *testing.T, f func())
help_test.go:13
↓ 7 callers
Method
CloneWith
CloneWith clones the current Vars and merges "vars" onto the clone.
options.go:39
↓ 7 callers
Function
ConfigureHelp
ConfigureHelp sets the HelpOptions to use for printing help.
options.go:328
↓ 7 callers
Method
Get
Get returns the value of the given tag. Note that this will return the empty string if the tag is missing.
tag.go:358
↓ 7 callers
Function
Visit
Visit all nodes.
visit.go:16
↓ 7 callers
Method
add
(values ...any)
callbacks.go:72
↓ 6 callers
Method
Decode
Decode ctx.Value with ctx.Scanner into target.
mapper.go:120
↓ 6 callers
Method
FatalIfErrorf
FatalIfErrorf terminates with an error message if err != nil. If the error implements the ExitCoder interface, the ExitCode() method is called and the
kong.go:469
↓ 6 callers
Function
Parse
Parse constructs a new parser and parses the default command-line.
global.go:8
↓ 6 callers
Method
Path
Path through ancestors to this Node.
model.go:228
↓ 6 callers
Method
PopValue
PopValue pops a value token, or returns an error. "context" is used to assist the user if the value can not be popped, eg. "expected <context> value
scanner.go:172
↓ 6 callers
Method
Printf
Printf writes a message to Kong.Stdout with the application name prefixed.
kong.go:449
↓ 5 callers
Method
ForValue
ForValue looks up the Mapper for a reflect.Value.
mapper.go:178
↓ 5 callers
Method
PeekAll
PeekAll remaining tokens
scanner.go:216
↓ 5 callers
Method
Selected
Selected command or argument.
context.go:166
↓ 5 callers
Method
ShortSummary
ShortSummary returns a human-readable summary of the value, not including any placeholders/defaults.
model.go:300
↓ 5 callers
Function
UsageOnError
UsageOnError configures Kong to display context-sensitive usage if FatalIfErrorf is called with an error.
options.go:391
↓ 5 callers
Method
Vars
(ctx *Value)
mapper.go:125
↓ 5 callers
Method
addProvider
(provider any, singleton bool)
callbacks.go:85
↓ 5 callers
Function
sliceDecoder
(r *Registry)
mapper.go:536
↓ 4 callers
Function
Bind
Bind binds values for hooks and Run() function arguments. Any arguments passed will be available to the receiving hook functions, but may be omitted.
options.go:234
↓ 4 callers
Function
BindTo
BindTo allows binding of implementations to interfaces. BindTo(impl, (*iface)(nil))
options.go:244
↓ 4 callers
Method
InferredType
InferredType tries to infer the type of a token.
scanner.go:80
↓ 4 callers
Method
IsBool
()
mapper.go:133
↓ 4 callers
Method
Len
Len returns the number of input arguments.
scanner.go:146
↓ 4 callers
Function
Must
Must creates a new Parser or panics if there is an error.
kong.go:27
↓ 4 callers
Method
Node
Node returns the Node associated with this Path, or nil if Path is a non-Node.
context.go:36
↓ 4 callers
Function
PostBuild
PostBuild provides read/write access to kong.Kong after initial construction of the model is complete but before parsing occurs. This is useful for,
options.go:125
↓ 4 callers
Method
Printf
(format string, args ...any)
help.go:402
↓ 4 callers
Function
Scan
Scan creates a new Scanner from args with untyped tokens.
scanner.go:128
↓ 4 callers
Function
SplitEscaped
SplitEscaped splits a string on a separator. It differs from strings.Split() in that the separator can exist in a field by escaping it with a \. eg.
mapper.go:852
↓ 4 callers
Function
Trace
Trace path of "args" through the grammar tree. The returned Context will include a Path of all commands, arguments, positionals and flags. This just
context.go:102
↓ 4 callers
Method
clone
Clone and add values.
callbacks.go:106
↓ 4 callers
Method
getValue
(value *Value)
context.go:668
↓ 4 callers
Function
interpolate
Interpolate variables from vars into s for substrings in the form ${var} or ${var=default}.
interpolate.go:22
↓ 4 callers
Function
newEmptyTag
()
tag.go:190
↓ 4 callers
Function
withHook
withHook registers a named hook.
options.go:154
↓ 4 callers
Function
writeTwoColumns
(w *helpWriter, rows [][2]string)
help.go:469
↓ 3 callers
Method
AllFlags
AllFlags returns flags from all ancestor branches encountered. If "hide" is true hidden flags will be omitted.
model.go:95
↓ 3 callers
Method
Apply
(k *Kong)
options.go:17
↓ 3 callers
Function
Configuration
Configuration provides Kong with support for loading defaults from a set of configuration files. Paths will be opened in order, and "loader" will be
options.go:459
↓ 3 callers
Method
FormatPlaceHolder
FormatPlaceHolder formats the placeholder string for a Flag.
model.go:447
↓ 3 callers
Method
FullPath
FullPath is like Path() but includes the Application root node.
model.go:211
↓ 3 callers
Method
IsCumulative
IsCumulative returns true if the type can be accumulated into.
model.go:333
↓ 3 callers
Method
IsEOL
IsEOL returns true if this Token is past the end of the line.
scanner.go:65
↓ 3 callers
Method
IsValue
IsValue returns true if token is usable as a parseable value. A parseable value is either a value typed token, or an untyped token NOT starting with
scanner.go:99
↓ 3 callers
Function
JSON
nolint: revive JSON returns a Resolver that retrieves values from a JSON source. Flag names are used as JSON keys indirectly, by trying snake_case an
resolver.go:33
↓ 3 callers
Method
Leaves
Leaves returns the leaf commands/arguments under Node. If "hidden" is true hidden leaves will be omitted.
model.go:115
↓ 3 callers
Function
NamedMapper
NamedMapper registers a mapper to a name.
options.go:207
↓ 3 callers
Function
NewRegistry
NewRegistry creates a new (empty) Registry.
mapper.go:158
↓ 3 callers
Method
PushTyped
PushTyped pushes a typed token onto the front of the Scanner.
scanner.go:227
↓ 3 callers
Method
RegisterDefaults
RegisterDefaults registers Mappers for all builtin supported Go types and some common stdlib types.
mapper.go:265
↓ 3 callers
Method
Resolve
Resolve the value for a Flag.
resolver.go:17
↓ 3 callers
Function
ScanAsType
ScanAsType creates a new Scanner from args with the given type.
scanner.go:119
↓ 3 callers
Function
ScanFromTokens
ScanFromTokens creates a new Scanner from a slice of tokens.
scanner.go:133
↓ 3 callers
Function
ValueMapper
ValueMapper registers a mapper to a field value.
options.go:199
↓ 3 callers
Function
atLeastOneEnvSet
(envs []string)
context.go:1216
↓ 3 callers
Function
build
(k *Kong, ast any)
build.go:15
↓ 3 callers
Function
buildNode
Build a Node in the Kong data model. "v" is the value to create the node from, "typ" is the output Node type.
build.go:139
↓ 3 callers
Function
failField
(parent reflect.Value, field reflect.StructField, format string, args ...any)
kong.go:18
↓ 3 callers
Function
getMethod
(value reflect.Value, name string)
callbacks.go:121
↓ 3 callers
Function
jsonTranscode
(in, out any)
mapper.go:943
↓ 3 callers
Method
merge
(other bindings)
callbacks.go:114
↓ 3 callers
Function
negatableFlagName
negatableFlagName returns the name of the flag for a negatable field, or an empty string if the field is not negatable.
negatable.go:10
↓ 3 callers
Method
printHelp
(options HelpOptions)
context.go:909
↓ 2 callers
Function
BindToProvider
BindToProvider binds an injected value to a provider function. The provider function must have one of the following signatures: func(...) (T, error
options.go:269
↓ 2 callers
Method
Call
Call an arbitrary function filling arguments with bound values.
context.go:819
↓ 2 callers
Method
EnumSlice
EnumSlice returns a slice of the enums in this value.
model.go:290
↓ 2 callers
Method
Error
()
context.go:816
↓ 2 callers
Method
Fatalf
Fatalf writes a message to Kong.Stderr with the application name prefixed then exits with status 1.
kong.go:461
↓ 2 callers
Method
ForNamedType
ForNamedType finds a mapper for a type with a user-specified name. Will return nil if a mapper can not be determined.
mapper.go:188
↓ 2 callers
Method
ForType
ForType finds a mapper from a type, by type, then kind. Will return nil if a mapper can not be determined.
mapper.go:198
↓ 2 callers
Function
HasInterpolatedVar
HasInterpolatedVar returns true if the variable "v" is interpolated in "s".
interpolate.go:11
↓ 2 callers
Method
Help
This string is formatted by go/doc and thus has the same formatting rules.
help.go:79
↓ 2 callers
Function
IgnoreFields
IgnoreFields will cause kong.New() to skip field names that match any of the provided regex patterns. This is useful if you are not able to add a kong
options.go:430
↓ 2 callers
Method
Indent
Indent returns a new helpWriter indented by two characters.
help.go:411
↓ 2 callers
Method
IsAny
IsAny returns true if the token's type is any of those provided.
scanner.go:70
next →
1–100 of 738, ranked by callers