Skip to content

radosgw-admin: migrate bucket and script command parsing to CLI11 - #69145

Open
Rotemrs wants to merge 4 commits into
ceph:mainfrom
Rotemrs:rgw-cli11-migration
Open

Rotemrs wants to merge 4 commits into
ceph:mainfrom
Rotemrs:rgw-cli11-migration

Conversation

@Rotemrs

@Rotemrs Rotemrs commented May 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR is the first stage of modernizing radosgw-admin's command-line interface. It incrementally migrates the argument parsing to CLI11, a modern header-only C++ command-line parsing library. This establishes a single source of truth for command definitions while making the CLI easier to maintain and enabling automatic generation of the --help output and the man page.

Related tracker: https://tracker.ceph.com/issues/74508

The migration focuses on preserving backwards compatibility through an incremental migration strategy, allowing migrated and legacy commands to coexist throughout the transition. This PR migrates the script commands, the bucket commands and global option handling to CLI11. The remaining command families will be migrated incrementally in later PRs.


Background

radosgw-admin has grown to ~220 commands and ~160 flags over time.

The radosgw-admin user-facing reference documentation, including the --help output and the man page (doc/man/8/radosgw-admin.rst), is maintained manually through separate mechanisms. In practice, the documentation falls out of sync: an audit found 68 commands and 46 flags present in --help but missing from the man page. The --help output is also limited to a single flat listing of commands and options, rather than providing context-aware, command-specific help. These issues have repeatedly affected users (e.g. tracker #40525, #12423, #58310, #44568).

In addition, the command line is handled by several separate mechanisms: a long argument-parsing loop that scans the arguments and sets hundreds of local variables, initialization code that processes a subset of options before command execution, and a separate lookup that matches the command words to the operation to execute. As a result, information about commands, options, and their behavior is spread across multiple parts of the implementation, making the code harder to maintain and evolve.


Goals

  • Define commands and their options once, in code, and automatically generate the --help output and the man page from the same definitions.

  • Provide hierarchical, context-aware help for individual commands.

  • Improve maintainability by keeping each command's definition, options, and behavior together.

  • Preserve backwards compatibility with the existing CLI throughout the migration.

  • Migrate incrementally, keeping the tool fully functional throughout the transition.


Approach

The project incrementally introduces CLI11 into radosgw-admin to define migrated commands, their options, and their descriptions. These definitions are used for argument parsing today and will later be used to automatically generate the --help output and the man page.

To keep the migration safe, reviewable, and backwards compatible, each command family is migrated incrementally. The migration focuses on moving the argument parsing to CLI11 while existing command implementations are reused unchanged. For each migrated command, the set of supported options for that command is derived from the existing implementation. Command and option descriptions are reused from the existing usage() text, and existing command metadata (for example whether a command is read-only or requires garbage collection) is preserved.

For example, a migrated three-level command, bucket logging flush, is defined in CLI11 as follows:

auto* bucket_cmd     = app.add_subcommand("bucket", "Manage buckets");
auto* bucket_logging = bucket_cmd->add_subcommand("logging", "manage bucket logging");

auto* bucket_logging_flush = bucket_logging->add_subcommand("flush",
    "flush pending log records object of source bucket to the log bucket");

add_multilevel_option(bucket_logging_flush, "--bucket,-b", bucket_name, bucket_desc);
add_multilevel_option(bucket_logging_flush, "--bucket-id", bucket_id, bucket_id_desc);

bucket_logging_flush->callback([&] {
  cli11_action = [&]() -> int {
    // the existing implementation, reused unchanged
  };
});

The callback captures the existing implementation, which is invoked later, after the required setup has completed.

CLI11 parses only the commands that have been migrated. A command it does not recognize is left untouched (allow_extras) and is handled by the existing legacy parser. Separately, the legacy flag-parsing loop still scans every flag on every run, even for migrated commands, so options are effectively parsed twice during migration; this is a transitional step, not a permanent routing mechanism, and goes away once the legacy parser is retired.


Backwards Compatibility

Every command contains years of implicit behavior that users and scripts rely on. The migration therefore aims to preserve existing behavior while it is in progress.

  • Warnings first, errors later. Where behavior changes are introduced, they follow a gradual migration path: warnings first, with errors only after users have had time to adapt.

  • Any-position flags. Without compatibility requirements, a flag in CLI11 would only be recognized at the specific command level where it's registered — CLI11 rejects it outright if it appears anywhere else, such as before its subcommand. Legacy, however, parsed flags before the command was even selected, so a flag could appear before, between, or after subcommands. To preserve this, migrated flags are registered at every level of their command; when a flag appears in an unexpected position, a warning is emitted instead of an error.

  • Global options. Three groups:

    • Flags used by many commands through shared initialization code (e.g. --tenant, --uid) are being made true globals — registered once, recognized at any position. Once a flag is made global, it's accepted on every command (even ones with no semantic use for it, as the nature of a global).
    • Identity/config flags parsed before CLI11 even runs (--conf, --id, --name, --cluster) continue to be handled by the existing early parser; CLI11 documents them in the help footer for every command.
    • Ceph's configuration options remain handled by the existing configuration system rather than being registered individually in CLI11.
  • Duplicate flags. Without compatibility requirements, CLI11 would reject a flag passed more than once outright (--bucket foo --bucket bar fails to parse at all). Instead, legacy's "last value wins" behavior is preserved by explicitly configuring the option to accept repeats, now paired with a warning instead of staying silent about it.

  • Binary flags. Without compatibility requirements, migrated binary flags could use CLI11's native boolean flags. Instead, legacy parsing behavior is preserved by registering these flags as strings and parsing them ourselves, matching how legacy handled them as integers rather than plain booleans - needed to match behavior such as --fix false (the space-separated form). One legacy quirk is preserved as-is, but made visible: --fix=banana used to silently set the flag to true (an invalid value was stored as an error code that happened to be truthy) - the new parser still accepts it and still treats it as true, but now emits a warning instead of failing silently.

  • Integer parsing. Without compatibility requirements, migrated integer options could rely on CLI11's own base-detection (0x, 0, 0b prefixes read as hex/octal/binary). Instead, legacy's decimal-only parsing is preserved, requiring custom parsing rather than binding directly to CLI11's integer type. Plain decimal numbers behave identically either way, but legacy also accepts inputs CLI11 would otherwise reject - for example 08 (an invalid octal literal to CLI11, but a valid decimal 8 to legacy), or 10abc/abc (parsed as 10/0 by some legacy flags instead of being rejected entirely).

  • Aliases. Existing command and option aliases continue to be supported.

  • Flag spelling (dashes vs. underscores). Legacy accepted both spellings of a flag interchangeably (e.g. --check-objects and --check_objects). Migrated flags preserve this: underscore spellings are accepted as before, with an added warning pointing to the dash form.

  • Unrelated options. As legacy code does, on a migrated command CLI11 does not reject an option it doesn't recognize as part of that command, that is an existing option for other commands.

  • Unknown words. An unknown word (e.g. banana) causes a failure on a migrated command, the same as it did in legacy.

  • Unknown options. A truly unknown option (e.g. --banana) is rejected on migrated
    commands just as on legacy ones during the transition, the still-running legacy loop provides this rejection. once CLI11 owns the full option set, the rejection moves into the CLI11 path.

  • Error messages and exit codes. Migrated commands aim to match the error messages and exit codes of their legacy counterparts, but this isn't a strict guarantee in every case - some differences remain where an exact match wasn't practical.


Current Status

The migration is already underway. Several script commands, a growing subset of bucket commands, and global option handling have been migrated to CLI11, with compatibility behavior verified through existing and newly added tests
(src/test/cli/radosgw-admin/test_cli11_*.sh).

The current implementation demonstrates that migrated and legacy commands can coexist while preserving existing behavior. The incremental migration strategy has proven practical across multiple command families and global option handling, including commands with more complex compatibility requirements.


Future Work

  • Continue migrating the remaining command families to CLI11 using the same incremental migration strategy.

  • Continue refining the internal structure of the CLI implementation to improve readability, maintainability, and long-term evolution.

  • Revisit temporary compatibility mechanisms as the migration progresses.

  • Revisit the long-term organization and ownership of global option handling, evaluating whether additional categories of global options should be managed by CLI11.

  • Generate the --help output and man page directly from the CLI11 definitions.

Disclosure: AI was used as a development aid during the implementation (research, brainstorming, code generation, and language assistance). The AI-assisted code was manually reviewed, analyzed, and refined to fit the desired design. Where needed, different implementation approaches were explored before selecting the final solution. The resulting code was validated through automated tests and manual comparison with the existing behavior.

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

16 similar comments
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@Rotemrs
Rotemrs force-pushed the rgw-cli11-migration branch from ff4a283 to 6f70c26 Compare May 28, 2026 17:06
Comment thread .gitmodules Resolved
Comment thread src/rgw/radosgw-admin/radosgw-admin.cc Resolved
Comment thread src/rgw/radosgw-admin/radosgw-admin.cc Resolved
Comment thread src/rgw/radosgw-admin/radosgw-admin.cc Resolved
Comment thread src/rgw/radosgw-admin/radosgw-admin.cc Resolved
Comment thread src/rgw/radosgw-admin/radosgw-admin.cc Resolved
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

Comment thread src/rgw/radosgw-admin/radosgw-admin.cc Resolved
Comment thread src/rgw/radosgw-admin/radosgw-admin.cc Resolved
Comment thread src/rgw/radosgw-admin/radosgw-admin.cc Resolved
Comment thread src/rgw/radosgw-admin/radosgw-admin.cc Resolved
Comment thread src/rgw/radosgw-admin/radosgw-admin.cc Resolved
Comment thread src/rgw/radosgw-admin/radosgw-admin.cc Outdated

if (script_put->parsed()) {
script_put->callback(
[script_put, &str_script_ctx, &infile, &tenant,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty neat!

To further the consolidation of command code into the callback, could we pass in the CLI11 object and collect parameter values from that instead of binding them to variables in the root function scope? Personally I think it'd be preferable if we could just pass in some cli11 object here instead of str_script_ctx, infile and tenant (which have to be declared elsewhere in a massive list). I guess with 3 parameters it isn't too bad but it would not surprise me if we have commands with many more parameters, in which case this would get quite unwieldy.

I guess as an alternative, moving all the declarations into a smaller scope would help with separating things out? Or maybe we can just keep doing this for now and see how it goes with other commands? ¯\_(ツ)_/¯

Comment thread src/rgw/radosgw-admin/radosgw-admin.cc Resolved
Comment thread src/rgw/radosgw-admin/radosgw-admin.cc Resolved
Comment thread src/rgw/radosgw-admin/radosgw-admin.cc Resolved
@@ -4340,6 +4340,14 @@ int main(int argc, const char **argv)
add_multilevel_option(bucket_layout, "--tenant", tenant, tenant_desc);
add_multilevel_option(bucket_layout, "--format", format, format_desc);

// bucket chown options
add_multilevel_option(bucket_chown, "--bucket,-b", bucket_name, bucket_desc)->option_text("<bucket> REQUIRED");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a code organisation thing so not a functional difference and maybe this is just me but: It feels weird to me that we've separated the definition of the subcommand itself, the options/flags for that subcommand, and the callback/behaviour for that subcommand.

I think it would be preferable if the code were sliced by command rather than by type-of-specification, for example.

auto* cmd_bucket = app->add_subcommand("bucket")
cmd_bucket->require_subcommand()
// ...whatever other options for the bucket command as a whole

auto cmd_bucket_list = cmd_bucket->add_subcommand("list")
add_multilevel_option(cmd_bucket_list, "--max-entries")
cmd_bucket_list->callback(...)

auto cmd_bucket_stats = cmd_bucket->add_subcommand("stats")
// ..etc

That way when you want to add a new command (or edit an existing one), all the changes go in one place.
Thoughts?

@Rotemrs Rotemrs Jun 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the argument for keeping each command self-contained makes sense.

One alternative I considered was introducing small helpers for some of the frequently repeated bucket options. For example, a helper that registers --bucket on the bucket subcommands that use it, rather than repeating the same add_multilevel_option() call for each command. That would reduce some of the repetition, but it would also pull the code back toward grouping by option rather than by command, and make adding or modifying a command require touching multiple places.

So I'm leaning toward the per-command layout you suggested. Do you think that kind of deduplication is worth the tradeoff, or would you still prefer keeping each command self-contained?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I think the duplication is fine, largely because the definition of each option is very simple.

We already have shared constants for the descriptions of common parameters which I think is ok. I don't think I would even argue that the shared descriptions is even strictly necessary: its just a description, if its slightly different between commands then maybe thats fine! But as it stands now, I think having shared descriptions and duplicated definitions is unproblematic.

bucket_limit_check->callback(
[&uid_str, &user_id_arg, &cli11_readonly, &cli11_action,
&user, &bucket_op, &stream_flusher_ptr, &warnings_only, &metadata_key] {
user_id_arg.from_str(uid_str);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neither uid_str nor user_id_arg appear to be used here. but we reference user. Since uid is an option for bucket limit check rather than a global option, it is only available in this command, which suggests that the initialisation for user should happen in this function too?

I've not checked the other commands but I'd have similar concerns elsewhere, and this is why I'm interested in seeing how small we can get the list of captured variables to be in each command's lambda!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was looking into this and had a question about the scope of what you had in mind.

When you suggested that the user initialization should happen in the command, were you only referring to the driver->get_user(...) step, or were you thinking about moving more of the related initialization as well?

I noticed that after get_user() there's also tenant/namespace handling, and later the user id is propagated into bucket_op/user_op, so I wasn't sure where you would draw the boundary for making the command self-contained.

I can see how localizing some of this would make the command more self-contained, but I'm not sure how much of the shared initialization you were thinking of moving.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I'm just wrong, uid is one of the global options, right. Ok no in that case I think it makes sense to leave the user initialisation where it is.

Since neither uid_str nor user_id_arg are otherwise used in this callback though, does it make sense that they're set here? I see there's a shared initialisation further down in the big ceph_argparse loop. Is that not sufficient on its own? I see several of the bucket commands have this same pattern of capturing uid_str and user_id_arg just to call user_id_arg.from_str(uid_str).

@Rotemrs
Rotemrs force-pushed the rgw-cli11-migration branch from 7e5faf6 to 5545f5f Compare June 24, 2026 22:22
@Rotemrs Rotemrs changed the title radosgw-admin: migrate command parsing to CLI11 radosgw-admin: migrate bucket and script command parsing to CLI11 Nov 9, 2026
Add CLI11 as a submodule and parse the bucket and script commands
with CLI11. Commands not yet migrated are routed to the legacy parser.
Add shell test suites for the migrated commands in
src/test/cli/radosgw-admin/.

Signed-off-by: Rotem Shapira <[email protected]>
@adamemerson

Copy link
Copy Markdown
Contributor

@chardan Want to review some C++ modernization?

Update the expected exit codes that changed on main:
- set-min-shards now returns EINVAL (exit 22), not -EINVAL (exit 234).
- The commands that returned -ENOENT now exit 2, not 254.
- An unknown --access-key now exits 254 with "could not find user for
  access-key", as on main today.

Fix comments that no longer match the rows:
- Use the mapped exit codes (1 and 22), not CLI11's own codes
  (104, 106, 114).
- An unrelated flag in space form now takes its value and is warned
  about; it no longer leaves the value as a stray positional.

Check the "is not a valid option" warning also for the --fix and
--max-entries= rows, not only the space-form rows.

Signed-off-by: Rotem Shapira <[email protected]>
Return EPERM instead of a bare 1 in the CLI11 code.
Exit codes don't change, since EPERM is 1.

Fix the bucket rm warning to name the flag as it is spelled,
--inconsistent-index, not --inconsistent_index.
This changes text the user sees.
Update ERR_INCONSISTENT in test_cli11_bucket.sh to match.

In normalize_cli11_tokens, build the dash spelling of an underscore
option with std::replace instead of a character loop, and document the
underscore rewrite in the function's header comment.

Explain how add_multilevel_strict_int and add_multilevel_binary_flag
match the legacy parser, with a TODO for "--fix banana".

Reword or remove comments as asked in review.

Signed-off-by: Rotem Shapira <[email protected]>

@chardan chardan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really happy to see these changes, it's going to make working on the utility a much more pleasant and safe experience, and pave the way to other improvements. I see that other folks have made great comments and got further into this than I did-- so I think you're definitely heading in the right direction. Thanks again for your effort on these PRs!

#include <iostream>
#include <memory>
#include <CLI/CLI.hpp>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Probably a good choice, as CLI11 is flexible and mature. Some libraries involve less boilerplate and are a bit more modern in approach, but this is going to be a just tremendous improvement over what we've got now! Happy to see folks caring about this. (My experience with command-line libraries has been that slightly "stodgy" but flexible really isn't a bad thing.)

@@ -5,11 +5,16 @@
* Copyright (C) 2025 IBM

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to tweak this while we're here.

}
};

// Registers a value option at every level of the command tree: hidden on all

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like it's over-explaining..? Most of this sounds like it's the ordinary behavior of the library, are we basically re-explaining the documentation? Assume your audience has a reasonable understanding of similar command-line libraries, if not CLI11 itself.

On the other hand, perhaps better to have too much than too little. Think it over, and go with your taste.

CLI::Option* add_multilevel_strict_int(CLI::App* cmd, const std::string& name,
T& target, std::string_view desc = {}) {
const std::string primary = name.substr(0, name.find(','));
CLI::callback_t setter = [&target](const CLI::results_t& res) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a Ceph setter() kind of like an Irish, English, or Gordon setter()..?

const std::string primary = name.substr(0, name.find(','));
CLI::callback_t setter = [&target](const CLI::results_t& res) {
std::string err;
if constexpr (std::is_same_v<T, int>) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only for int? No one will request a short, or other numeric type, etc.? I somewhat feel like if the idea is to clamp it to a range we could use std::clamp() and what not..?

@chardan
chardan self-requested a review November 16, 2026 15:44

@chardan chardan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the comments from other reviewers have been resolved-- please double check to be sure any items that really needed attention are checked over. If that's the case, I think this is very welcome. +1.

@RaminNietzsche

Copy link
Copy Markdown
Member

I read @jacquesh's threads on ignore_underscore() and get_subcommands() and your replies — I agree with the direction (normalize_cli11_tokens + spelling warnings instead of ignore_underscore, and walking front() because CLI11 only exposes direct parsed children).

Two small follow-ups that I did not see in the review yet:

  1. Bare --: Legacy stops at ceph_argparse_double_dash(), but normalize_cli11_tokens() keeps going. For example bucket list -- --bucket_id x can still rewrite the token and print the spelling warning, while legacy would leave everything after -- alone. Edge case — maybe stop passing the rest through once a standalone -- is seen?

  2. test_cli11_*.sh in CI: run-cli-tests only picks up *.t cram tests, and qa/workunits/rgw/run-radosgw-admin-exit-codes.sh runs the src/test/rgw/radosgw-admin/*.sh suites, not these src/test/cli/radosgw-admin/test_cli11_*.sh scripts. Is the plan to keep them manual / pre-merge for now, or wire them into a workunit (or document how to run them) in a follow-up?

Optional: cli11_path around the legacy dispatch still walks parsed subcommands with the same front() pattern — could share a small helper with the post-parse warnings later so it does not drift.

Thanks for the careful compatibility work on this PR.

"bucket list --num-shards 5" warns that --num-shards is not a valid
option for 'bucket list', but "bucket list --num-shards" did not.
CLI11 fails on a flag with no value before storing it, so the warning
check, which only looks at stored flags, never saw it.

normalize_cli11_tokens now reports such a flag as missing_value_flag.
warn_wrong_position_and_unrelated_option warns about it when the
command does not own it.

Add check_exact to test_cli11_bucket.sh: it checks the whole output
line by line, so an unexpected extra warning fails the row.
Add rows for an unrelated flag given last with no value, and use
check_exact for four existing missing-value rows.

Signed-off-by: Rotem Shapira <[email protected]>
@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants