Summary
Cobra's generated Bash completion can remain constrained to the required-flag set even after a required flag has already been provided in normal two-word form.
This makes completion continue to behave as if the required flag is still missing, instead of expanding to the full valid set of flags for the command.
Expected behavior
Once a required flag has been supplied, Bash completion should treat it as satisfied whether it was entered as:
--flag=value
--flag value
After that, completion should no longer stay limited to only the required flags.
Actual behavior
When a required flag is entered in two-word form, the generated Bash completion script does not always clear the internal required-flag tracking. As a result, completion can continue to suggest only the required subset of flags.
Impact
This creates misleading and incomplete Bash completion behavior for commands that use required flags. Users may see completion output that does not reflect the current command state.
Suggested area to inspect
The Bash completion generation and handling logic for required flags, especially:
- how required flags are emitted into the generated script
- how the generated script tracks already-entered flags
- how Bash completion distinguishes between
--flag=value and --flag value
Suggested regression coverage
Add Bash completion tests that verify:
- a required flag entered as
--flag=value is recognized as satisfied
- a required flag entered as
--flag value is recognized as satisfied
- completion after either form no longer stays restricted to only the required flags
Summary
Cobra's generated Bash completion can remain constrained to the required-flag set even after a required flag has already been provided in normal two-word form.
This makes completion continue to behave as if the required flag is still missing, instead of expanding to the full valid set of flags for the command.
Expected behavior
Once a required flag has been supplied, Bash completion should treat it as satisfied whether it was entered as:
--flag=value--flag valueAfter that, completion should no longer stay limited to only the required flags.
Actual behavior
When a required flag is entered in two-word form, the generated Bash completion script does not always clear the internal required-flag tracking. As a result, completion can continue to suggest only the required subset of flags.
Impact
This creates misleading and incomplete Bash completion behavior for commands that use required flags. Users may see completion output that does not reflect the current command state.
Suggested area to inspect
The Bash completion generation and handling logic for required flags, especially:
--flag=valueand--flag valueSuggested regression coverage
Add Bash completion tests that verify:
--flag=valueis recognized as satisfied--flag valueis recognized as satisfied