-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accept profile argument in all subcommands #781
Conversation
32d43f3
to
9ec9af2
Compare
Customer report from https://oxidecomputer.slack.com/archives/C06QW63CYPM/p1723121576190879?thread_ts=1723121438.371029&cid=C06QW63CYPM The potential downside of this change is that it would prevent us from creating a |
The `profile` argument is associated with the top-level `oxide` command, meaning it must be applied before a subcommand is registered. It would be convenient to be able to specify this arg at any point in the command, such as when repeating the same command against different profiles. Set `global` to `true` for `profile` to allow this behavior.
9ec9af2
to
4deda4f
Compare
I am in favor of this — it came up on the original PR: A small downside is that it adds noise to the docs by adding |
I should note that I also have no problem hacking a fix into the docs site by hard coding a special case for the profile arg. Ideally temporarily, but it's so simple that it doesn't matter that much. |
I think the upside of having it be allowed at any level is worth the extra text within the options flags outputs. Also agreed that it is a small downside to have it repeated on the docs, but certainly not worth blocking on. I'm not sure how much custom work it would be to have global arguments that did not appear this way within clap. |
With f60ae65 (Accept profile argument in all subcommands (#781), 2024-08-08) we set the `--profile` arg as global, allowing all subcommands to inherit it. This is nice for usability, but adds a considerable amount of clutter to our docs, as it now shows there for each subcommand as well. Filter out `--profile` when generating the docs.
With f60ae65 (Accept profile argument in all subcommands (#781), 2024-08-08) we set `--profile` as a global arg, allowing all subcommands to accept it. This is good for useability, but a bit of a mess in the docs as it is now listed as an argument for all subcommands. Removing it entirely from the docs hurts discoverability, but we want to ensure it is clearly distinguished from the direct args for a subcommand. Adding a subsection of the docs page with global args would accomplish this. Add a new `global` bool for `JsonArg` to indicate whether a given arg is inherited.
With f60ae65 (Accept profile argument in all subcommands (#781), 2024-08-08) we set `--profile` as a global arg, allowing all subcommands to accept it. This is good for useability, but a bit of a mess in the docs as it is now listed as an argument for all subcommands. Removing it entirely from the docs hurts discoverability, but we want to ensure it is clearly distinguished from the direct args for a subcommand. Adding a subsection of the docs page with global args would accomplish this. Add a new `global` bool for `JsonArg` to indicate whether a given arg is inherited.
With f60ae65 (Accept profile argument in all subcommands (#781), 2024-08-08) we set `--profile` as a global arg, allowing all subcommands to accept it. This is good for useability, but a bit of a mess in the docs as it is now listed as an argument for all subcommands. Removing it entirely from the docs hurts discoverability, but we want to ensure it is clearly distinguished from the direct args for a subcommand. Adding a subsection of the docs page with global args would accomplish this. Add a new `global` bool for `JsonArg` to indicate whether a given arg is inherited.
The
profile
argument is associated with the top-leveloxide
command, meaning it must be applied before a subcommand is registered. It would be convenient to be able to specify this arg at any point in the command, such as when repeating the same command against different profiles.Set
global
totrue
forprofile
to allow this behavior.