Skip to content

plugins: stop using -v/-o short flags to avoid global option collisions#26

Draft
Copilot wants to merge 11 commits into
masterfrom
copilot/update-command-line-parser
Draft

plugins: stop using -v/-o short flags to avoid global option collisions#26
Copilot wants to merge 11 commits into
masterfrom
copilot/update-command-line-parser

Conversation

Copy link
Copy Markdown

Copilot AI commented May 29, 2026

  • Identify option renames that require documentation sync
  • Regenerate documentation artifacts so short options match renamed flags
  • Review and keep only relevant documentation changes
  • Validate repository still builds/tests with existing commands

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
Copilot finished work on behalf of igaw May 29, 2026 07:54
Copilot AI requested a review from igaw May 29, 2026 07:54
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
Copilot finished work on behalf of igaw May 29, 2026 13:05
Copilot AI added 3 commits May 29, 2026 13:29
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 finished work on behalf of igaw May 29, 2026 13:34
Copilot AI changed the title fix: correct argv/argc handling in handle_plugin so subcommands are not swallowed Handle top-level --help in global parsing and add regression coverage May 29, 2026
Copilot finished work on behalf of igaw May 29, 2026 15:00
Copilot AI changed the title Handle top-level --help in global parsing and add regression coverage Handle top-level --help/--version without getopt errors May 29, 2026
Copilot finished work on behalf of igaw May 29, 2026 15:12
Copilot AI changed the title Handle top-level --help/--version without getopt errors plugins: stop using -v/-o short flags to avoid global option collisions May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants