← Back to issue list

Avoid a duplicated -h/--help option when getting help for a command.

View original Github issue

Metadata

Project
charmcraft
Number
#207
Type
pull request
State
merged
Author
facundobatista
Labels
Created
Updated
Closed

Current evaluation

Merged a fix to eliminate duplicate -h/--help options in command help output by disabling ArgumentParser's automatic help flag addition. Existing tests were updated to expose duplicates. Approved by two reviewers and passed CI.

Suggested action:

No scores available.

Issue body

This was because we had two `-h/--help` options, one which is the global one (that works for the tool in general and for each command, as with any global option), and other specific for the command added by `ArgumentParser`. The fix is to tell `ArgumentParser` to not automatically add a help option. Regarding tests, no new one was needed, just improved the current ones to stop hiding duplicates.

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.6-35b-a3b Merged a fix to eliminate duplicate -h/--help options in command help output by disabling ArgumentParser's automatic help flag addition. Existing tests were updated to expose duplicates. Approved by two reviewers and passed CI.
qwen3.6-35b-a3b-mtp-q6 Merged fix for duplicated -h/--help options in command help. Configured ArgumentParser to skip auto-adding the help flag, resolving conflicts with the global option. Existing tests were updated to expose duplicate flags.
qwen3.6-35b-a3b-mtp-q6 Merged fix for duplicated -h/--help options in command help. Configured ArgumentParser to skip automatic help generation, resolving conflicts with the global flag. Existing tests were updated to properly detect duplicates.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#309 fix: hide positional arguments with no help craft-cli merged Merged, resolving issue #308. The change hides positional arguments without help text while preserving them in command syntax. Approved by two reviewers, passed CI checks, and updated three files (+102/-11 lines).
72%
#5178 fix: properly present help when posargs have no help snapcraft merged Merged fix for help display when positional arguments lack descriptions. Approved by two reviewers, passed CI, and applied with minimal changes across four files.
72%
#1686 fix(test): parse test command arguments charmcraft merged Merged a fix updating the test command to parse arguments directly instead of forwarding them raw to spread. This enables consistent double-dashed long options and improved help messages. Approved by two reviewers, modifying five files with 55 additions and 32 deletions.
71%
#109 Better tested help parsing function, with a bug fixed. craft-cli merged Merged after approval. Improved testing for the help parsing function and fixed a bug where errors were not properly raised when using the --all flag with extra arguments. Changes span two files with 100 additions and 12 deletions.
70%
#211 Exercise command parsers. charmcraft merged Merged fix for a bug where the help command always returned an error. Updates help logic to only error on actual failures and adds tests exercising all command parsers, resolving issue #210. Approved by two reviewers and passed CI.
70%