Comptplus is a fork of Cobra Prompt with added features, intended to enhance the original implementation by making it more versatile.
- Flag Completions: Added completions for flag values, for easier and more intuitive command usage.
- Default cache duration for refreshing flag value completions is set to 500ms, to avoid lag in user interaction.
- Support for flag descriptions by splitting on
\t
.
- Custom Flag Reset Behaviors: Ability to set custom behaviors for resetting flag values.
- The default flag reset behaviour has also been changed to reset flags to their default values after each command execution (rather than on each typed character).
- A bug in the original repo caused slice/array flags to be reset incorrectly, by appending the default values to the previous execution's values. This has been fixed in this fork.
- Execution Hooks: Ability to use
HookBefore
andHookAfter
for performing actions before and after command execution.
- Bump go-prompt: Switched to an actively maintained fork of go-prompt with more features and bug fixes: https://github.com/elk-language/go-prompt. Sadly this involves some breaking changes.
- This fixes a bug which would disallow usage of CTRL + C in after usage of go-prompt.
Cobra-prompt makes every Cobra command and flag available for go-prompt.
- Traverse cobra command tree. Every command and flag will be available.
- Persist flag values.
- Add custom functions for dynamic suggestions.
Get the module:
go get github.com/stromland/cobra-prompt
cd _example
go build -o cobra-prompt
./cobra-prompt