* Replace all non-alphanumerics in active help env var program prefix
There are other characters besides the dash that are fine in program
names, but are problematic in environment variable names. These include
(but are not limited to) period, space, and non-ASCII letters.
* Another change in docs to mention non-ASCII-alphanumeric instead of just dash
Currently, only one of the persistent pre-runs and post-runs is executed.
It is always the first one found in the parents chain, starting at this command.
Expected behavior is to execute all parents' persistent pre-runs and post-runs.
Dependent projects implemented various workarounds for this:
- manually building persistent hook chains (in every hook).
- applying some kind of monkey-patching on top of Cobra.
This change eliminates the necessity for such workarounds
by allowing to set a global variable EnableTraverseRunHooks.
Tickets:
- https://github.com/spf13/cobra/issues/216
- https://github.com/spf13/cobra/issues/252
Signed-off-by: Volodymyr Khoroz <volodymyr.khoroz@foundries.io>
When a program has no sub-commands, its root command can accept
arguments. If we add the default "completion" command to such programs
they will now have a sub-command and will no longer accept arguments.
What we do instead for this special case, is only add the "completion"
command if it is being called, or if it is being completed itself.
We want to have the "completion" command for such programs because it
will allow the completion of flags and of arguments (if provided
by the program).
Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>