Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( CmdsOpts = Combine{Cmds, Opts} CmdsAliases = Combine{Cmds, Aliases} CmdsAliasesOpts = Combine{Cmds, Aliases, Opts} FileDirCmdsOpts = Combine{FileDir, CmdsOpts} FileDirCmdsAliasesOpts = Combine{FileDir, CmdsAliasesOpts} )
var Aliases = new(aliases)
Aliases is a bonzai.Completer for all available bonzai.Cmd.Aliases including bonzai.Cmd.Name.
var Cmds = new(cmds)
Cmds is a bonzai.Completer for all available bonzai.Cmd.Cmds. It excludes hidden commands.
var FileDir = fileDir{}
FileDir is a bonzai.Completer that completes for file names. This [Completer] is roughly based on the behavior of the bash shell with forward slashes as separators and escaped spaces. By using this completer (instead of the shell) the command line interface remains consistent across all runtimes. Note that unlike bash completion no indication of the type of file is provided (i.e. dircolors support).
var Opts = new(opts)
Opts is a bonzai.Completer for all available bonzai.Cmd.Opts.
Functions ¶
This section is empty.
Types ¶
type Combine ¶
type Combine []any
Example (Transform) ¶
package main import ( "fmt" "github.com/rwxrob/bonzai" "github.com/rwxrob/bonzai/comp" "github.com/rwxrob/bonzai/fn/tr" ) func main() { foo := &bonzai.Cmd{ Name: `foo`, Opts: `box`, Comp: comp.Combine{comp.CmdsOpts, tr.Prefix{`aprefix`}}, Cmds: []*bonzai.Cmd{{Name: `bar`}, {Name: `blah`}}, } foo.Comp.(bonzai.CmdCompleter).SetCmd(foo) // we know it's not a command, but no prefix just yet // (usually this is when a space has been added after the command) fmt.Println(foo.Comp.Complete("")) // everything that begins with a (nothing) fmt.Println(foo.Comp.Complete(`a`)) // everything that begins with b (which is everything) fmt.Println(foo.Comp.Complete(`b`)) // everything that begins with bl (just blah) fmt.Println(foo.Comp.Complete(`bl`)) }
Output: [aprefixbar aprefixblah aprefixbox] [] [aprefixbar aprefixblah aprefixbox] [aprefixblah]
type Env ¶ added in v0.10.0
type Env struct { // Prefix is prepended to the environment variable search. // For example, if Prefix is "APP_", only environment variables // starting with "APP_" will be included in completions. Prefix string // Insensitive determines if case-insensitive matching should be used. // When true, "path" will match "PATH", "Path", "path", etc. Insensitive bool }
Env defines the configuration for environment variable completion.