MCPcopy Create free account

hub / github.com/alecthomas/kong / functions

Functions738 in github.com/alecthomas/kong

↓ 241 callersMethodParse
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 callersFunctionmustNew
(t *testing.T, cli any, options ...kong.Option)
kong_test.go:17
↓ 68 callersFunctionNew
New creates a new Kong parser on grammar. See the README (https://github.com/alecthomas/kong) for usage instructions.
kong.go:82
↓ 62 callersMethodErrorf
Errorf writes a message to Kong.Stderr with the application name prefixed.
kong.go:455
↓ 61 callersMethodError
()
options_test.go:85
↓ 47 callersMethodString
()
tag.go:62
↓ 38 callersFunctionExit
Exit overrides the function used to terminate. This is useful for testing or interactive use.
options.go:51
↓ 37 callersFunctionWriters
Writers overrides the default writers. Useful for testing or interactive use.
options.go:215
↓ 22 callersMethodRun
()
kong_test.go:860
↓ 19 callersFunctionDescription
Description sets the application description.
options.go:175
↓ 18 callersFunctionName
Name overrides the application name.
options.go:167
↓ 18 callersMethodPopValueInto
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 callersMethodSet
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 callersMethodSummary
Summary help string for the node (not including application name).
model.go:159
↓ 12 callersMethodRun
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 callersFunctionnewEnvParser
(t *testing.T, cli any, env envMap, options ...kong.Option)
resolver_test.go:16
↓ 11 callersMethodPop
Pop the front token off the Scanner.
scanner.go:151
↓ 10 callersFunctionExpandPath
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 callersMethodCommand
Command returns the full command path.
context.go:303
↓ 9 callersFunctionResolvers
Resolvers registers flag resolvers.
options.go:417
↓ 8 callersMethodPeek
Peek at the next Token or return an EOLToken.
scanner.go:208
↓ 8 callersMethodPrint
(text string)
help.go:406
↓ 8 callersFunctioncallFunction
(f reflect.Value, bindings bindings)
callbacks.go:205
↓ 8 callersFunctionpanicsTrue
(t *testing.T, f func())
help_test.go:13
↓ 7 callersMethodCloneWith
CloneWith clones the current Vars and merges "vars" onto the clone.
options.go:39
↓ 7 callersFunctionConfigureHelp
ConfigureHelp sets the HelpOptions to use for printing help.
options.go:328
↓ 7 callersMethodGet
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 callersFunctionVisit
Visit all nodes.
visit.go:16
↓ 7 callersMethodadd
(values ...any)
callbacks.go:72
↓ 6 callersMethodDecode
Decode ctx.Value with ctx.Scanner into target.
mapper.go:120
↓ 6 callersMethodFatalIfErrorf
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 callersFunctionParse
Parse constructs a new parser and parses the default command-line.
global.go:8
↓ 6 callersMethodPath
Path through ancestors to this Node.
model.go:228
↓ 6 callersMethodPopValue
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 callersMethodPrintf
Printf writes a message to Kong.Stdout with the application name prefixed.
kong.go:449
↓ 5 callersMethodForValue
ForValue looks up the Mapper for a reflect.Value.
mapper.go:178
↓ 5 callersMethodPeekAll
PeekAll remaining tokens
scanner.go:216
↓ 5 callersMethodSelected
Selected command or argument.
context.go:166
↓ 5 callersMethodShortSummary
ShortSummary returns a human-readable summary of the value, not including any placeholders/defaults.
model.go:300
↓ 5 callersFunctionUsageOnError
UsageOnError configures Kong to display context-sensitive usage if FatalIfErrorf is called with an error.
options.go:391
↓ 5 callersMethodVars
(ctx *Value)
mapper.go:125
↓ 5 callersMethodaddProvider
(provider any, singleton bool)
callbacks.go:85
↓ 5 callersFunctionsliceDecoder
(r *Registry)
mapper.go:536
↓ 4 callersFunctionBind
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 callersFunctionBindTo
BindTo allows binding of implementations to interfaces. BindTo(impl, (*iface)(nil))
options.go:244
↓ 4 callersMethodInferredType
InferredType tries to infer the type of a token.
scanner.go:80
↓ 4 callersMethodIsBool
()
mapper.go:133
↓ 4 callersMethodLen
Len returns the number of input arguments.
scanner.go:146
↓ 4 callersFunctionMust
Must creates a new Parser or panics if there is an error.
kong.go:27
↓ 4 callersMethodNode
Node returns the Node associated with this Path, or nil if Path is a non-Node.
context.go:36
↓ 4 callersFunctionPostBuild
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 callersMethodPrintf
(format string, args ...any)
help.go:402
↓ 4 callersFunctionScan
Scan creates a new Scanner from args with untyped tokens.
scanner.go:128
↓ 4 callersFunctionSplitEscaped
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 callersFunctionTrace
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 callersMethodclone
Clone and add values.
callbacks.go:106
↓ 4 callersMethodgetValue
(value *Value)
context.go:668
↓ 4 callersFunctioninterpolate
Interpolate variables from vars into s for substrings in the form ${var} or ${var=default}.
interpolate.go:22
↓ 4 callersFunctionnewEmptyTag
()
tag.go:190
↓ 4 callersFunctionwithHook
withHook registers a named hook.
options.go:154
↓ 4 callersFunctionwriteTwoColumns
(w *helpWriter, rows [][2]string)
help.go:469
↓ 3 callersMethodAllFlags
AllFlags returns flags from all ancestor branches encountered. If "hide" is true hidden flags will be omitted.
model.go:95
↓ 3 callersMethodApply
(k *Kong)
options.go:17
↓ 3 callersFunctionConfiguration
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 callersMethodFormatPlaceHolder
FormatPlaceHolder formats the placeholder string for a Flag.
model.go:447
↓ 3 callersMethodFullPath
FullPath is like Path() but includes the Application root node.
model.go:211
↓ 3 callersMethodIsCumulative
IsCumulative returns true if the type can be accumulated into.
model.go:333
↓ 3 callersMethodIsEOL
IsEOL returns true if this Token is past the end of the line.
scanner.go:65
↓ 3 callersMethodIsValue
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 callersFunctionJSON
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 callersMethodLeaves
Leaves returns the leaf commands/arguments under Node. If "hidden" is true hidden leaves will be omitted.
model.go:115
↓ 3 callersFunctionNamedMapper
NamedMapper registers a mapper to a name.
options.go:207
↓ 3 callersFunctionNewRegistry
NewRegistry creates a new (empty) Registry.
mapper.go:158
↓ 3 callersMethodPushTyped
PushTyped pushes a typed token onto the front of the Scanner.
scanner.go:227
↓ 3 callersMethodRegisterDefaults
RegisterDefaults registers Mappers for all builtin supported Go types and some common stdlib types.
mapper.go:265
↓ 3 callersMethodResolve
Resolve the value for a Flag.
resolver.go:17
↓ 3 callersFunctionScanAsType
ScanAsType creates a new Scanner from args with the given type.
scanner.go:119
↓ 3 callersFunctionScanFromTokens
ScanFromTokens creates a new Scanner from a slice of tokens.
scanner.go:133
↓ 3 callersFunctionValueMapper
ValueMapper registers a mapper to a field value.
options.go:199
↓ 3 callersFunctionatLeastOneEnvSet
(envs []string)
context.go:1216
↓ 3 callersFunctionbuild
(k *Kong, ast any)
build.go:15
↓ 3 callersFunctionbuildNode
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 callersFunctionfailField
(parent reflect.Value, field reflect.StructField, format string, args ...any)
kong.go:18
↓ 3 callersFunctiongetMethod
(value reflect.Value, name string)
callbacks.go:121
↓ 3 callersFunctionjsonTranscode
(in, out any)
mapper.go:943
↓ 3 callersMethodmerge
(other bindings)
callbacks.go:114
↓ 3 callersFunctionnegatableFlagName
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 callersMethodprintHelp
(options HelpOptions)
context.go:909
↓ 2 callersFunctionBindToProvider
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 callersMethodCall
Call an arbitrary function filling arguments with bound values.
context.go:819
↓ 2 callersMethodEnumSlice
EnumSlice returns a slice of the enums in this value.
model.go:290
↓ 2 callersMethodError
()
context.go:816
↓ 2 callersMethodFatalf
Fatalf writes a message to Kong.Stderr with the application name prefixed then exits with status 1.
kong.go:461
↓ 2 callersMethodForNamedType
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 callersMethodForType
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 callersFunctionHasInterpolatedVar
HasInterpolatedVar returns true if the variable "v" is interpolated in "s".
interpolate.go:11
↓ 2 callersMethodHelp
This string is formatted by go/doc and thus has the same formatting rules.
help.go:79
↓ 2 callersFunctionIgnoreFields
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 callersMethodIndent
Indent returns a new helpWriter indented by two characters.
help.go:411
↓ 2 callersMethodIsAny
IsAny returns true if the token's type is any of those provided.
scanner.go:70
next →1–100 of 738, ranked by callers