plugins: stop using -v/-o short flags to avoid global option collisions#26
Draft
Copilot wants to merge 11 commits into
Draft
plugins: stop using -v/-o short flags to avoid global option collisions#26Copilot wants to merge 11 commits into
-v/-o short flags to avoid global option collisions#26Copilot wants to merge 11 commits into
Conversation
Copilot
AI
changed the title
Allow global options before subcommand; split help into sections
argconfig: allow global options before subcommand; split help into sections
May 29, 2026
The plugin parser uses its own NVME_ARGS opts array, so seen flags set during the global pre-parse in main() were not reflected in each command function's own opts. This meant that global options like --dry-run, --no-ioctl-probing, --verbose etc. were silently ignored when specified before the subcommand name. Fix by moving argconfig_parse_global() from main() into handle_plugin() so global options are stripped from argv at each dispatch level before the subcommand name is read. main() now simply passes argc-1/argv+1. Also replace all argconfig_parse_seen() calls for the four global options with direct reads of nvme_args.*: - dry-run -> nvme_args.dry_run - no-ioctl-probing -> nvme_args.no_ioctl_probing - timeout (seen check) -> removed; nvme_args.timeout != default suffices - verbose -> nvme_args.verbose (nvme.c x36, netapp plugin x2)
Copilot
AI
changed the title
argconfig: allow global options before subcommand; split help into sections
fix: move global option parsing into handle_plugin
May 29, 2026
getopt_long always skips argv[0] as the program name. The previous code called handle_plugin(argc-1, &argv[1], ...) from main(), stripping the program name, so inside handle_plugin the call to argconfig_parse_global treated the actual subcommand (argv[0]) as the program name and silently discarded it. After argc -= optind; argv += optind the subcommand was gone and general_help() fired instead of dispatching the command. Fix: - main() now passes argc, argv (with "nvme" at argv[0]) to handle_plugin - Normal plugin recursive dispatch uses handle_plugin(argc, argv, ...) so argv[0] (the plugin name, e.g. "intel") serves as the placeholder that getopt skips, and argv[1] is the subcommand - Combined invocation (e.g. "intel-smart-add-log") builds a temporary argv with the extension name prepended as the program-name placeholder Also add unit tests for argconfig_parse_global in unit/test-argconfig-parse.c covering: subcommand-only, short/long --verbose, repeated flags, --dry-run, option-after-subcommand (+ stop), options-only, and program-name-only cases.
Copilot
AI
changed the title
fix: move global option parsing into handle_plugin
fix: correct argv/argc handling in handle_plugin so subcommands are not swallowed
May 29, 2026
Copilot
AI
changed the title
fix: correct argv/argc handling in handle_plugin so subcommands are not swallowed
Handle top-level May 29, 2026
--help in global parsing and add regression coverage
Copilot
AI
changed the title
Handle top-level
Handle top-level May 29, 2026
--help in global parsing and add regression coverage--help/--version without getopt errors
Copilot
AI
changed the title
Handle top-level
plugins: stop using May 29, 2026
--help/--version without getopt errors-v/-o short flags to avoid global option collisions
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.