-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: complex command and subcommand descriptions and completions. #77
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
can parse config file with exec:invoker where invoker can be a complex type describing help, args, completion and sub-args keeps compatibility with simple slice args case
Makes the config a private member as it is now accessed only from the summon package. We normalize earlier the invokers and handles. Because handles are unique, we make a global map of them, derived from the config. We now use these normalized structs throughout. This removes CmdSpec computing duplication. This also allows failing fast if duplicated handle are detected.
Boxes were a packr concept, this commit removes the remnants of the box name.
This allows failling fast (faster than at command execution). We cannot recover from a badly formed config file so might as well fail as soon as we can.
Invoker is more of an execution environment where you start processes. And CmdArgs is really the Cmd and args.
This was the early version of the now more relevant CmdSpec. Everything we need to invoke a target is now in the CmdSpec. Removed environment exec support as this did not make sense in container contexts. Templates can be used to vary environment in the ExecEnvironment.
flags to be rendered cannot be stored in a map as iteration is non-deterministic. Also, return userValue when the flag is evaluated.
Otherwize this will introduce empty args when invoking the command. Allow for empty args if the result is an empty array.
This is part of the interface to summon. Every call to completion must yield a '\n' separated completion string. If the underlying call cannot generate that, you can template your way with a join "\n" $result.
Global flags (at invoker level) are marked global, others are marked local to the command.
Handles are executed in a specified execution environment.
When subcmds have arg hints (subcmd [hint]) it is not findable by the subcmd (args) map. Use prefix to allow user to use hint as this is practical in reflected help.
What we are combining is actually args, not a cmd. And we are specifying a subCmd not args. This is of course a breaking change, but included in the config change that is breaking anyhow.
Before this change, SubCmds could not use ArgSliceSpec and this was confusing. The solution is to generalize the config part and normalize to a CmdSpec and FlagSpec, recursively.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This has been cooking for a long time.
This long commit series introduces a way to describe complex sub-commands to taylor declarative command line interfaces to a proxied command. Not very useful when targeting an installed command, but very powerful when targeting docker containers.
It essentially allows tailoring a command-line to a container, which is typically hard to invoke (volume mounts, environment settings, image repository name, etc). Supports help, completions and flags.
This change also leverages cobra's dynamic completions. This allows delegating completion to a program inside the container. I use it to give a better cli to a makefile program (a series of utility makefile targets) which typically has poor user oriented command line UX.
closes #67