Documentation ¶
Overview ¶
Package compflag generates bash completions on-the-fly from stdlib flag values.
Usage - just call compflag.Complete() somewhere before actual app logic, best point is right at the start:
func main() { if compflag.Complete() { os.Exit(0) } flag.Parse() // other startup logic... }
Please note, that you need to exit app if any completion happened.
Build your app, put binary somewhere in your "PATH", then run:
complete -C %your-binary-name% %your-binary-name%
Now enter "%your-binary-name%", and hit tab twice )
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrUnknownShell = errors.New("shell unknown")
Functions ¶
Types ¶
type Option ¶
type Option func(*options)
Option is a functional option type.
func WithExitFunc ¶ added in v1.1.0
WithExitFunc set custom exit handler on successful complete.
func WithFlagSet ¶
WithFlagSet set custom flag.FlagSet as completion source.
func WithHidden ¶
WithHidden hides given options from completion.
Click to show internal directories.
Click to hide internal directories.