Summary
Two related problems on auth switch:
- It takes a positional
<NAME>, but the global --profile flag is also accepted — those
mean nearly the same thing, and the invocation that finally works passes the same profile
name twice.
--help and the error-path usage strings don't agree. The same command reports three
different signatures depending on how you invoke it, so there's no single authoritative
answer to "what is the correct syntax?"
What happened
Trying to make develop-okta the active profile:
$ jr-a auth switch --profile develop-okta
error: the following required arguments were not provided:
<NAME>
Usage: jr-a auth switch --profile <PROFILE> <NAME>
That usage line reads as though --profile <PROFILE> is a required part of switch. So the
obvious next guess is that the name is also a flag:
$ jr-a auth switch --profile develop-okta --name develop-okta
error: unexpected argument '--name' found
tip: to pass '--name' as a value, use '-- --name'
Usage: jr-a auth switch --profile <PROFILE> <NAME>
Still the same usage line. Eventually this worked:
$ jr-a auth switch --profile "develop-okta" "develop-okta"
Active profile set to "develop-okta"
…which is the same value supplied twice. Meanwhile the bare form was correct all along:
$ jr-a auth switch
error: the following required arguments were not provided:
<NAME>
Usage: jr-a auth switch <NAME>
The usage strings and --help disagree
This is the part that made the above unsolvable by reading. The same subcommand advertises
three different signatures:
| Source |
Reported usage |
jr-a auth switch --help |
jr-a auth switch [OPTIONS] <NAME> |
error, bare jr-a auth switch |
jr-a auth switch <NAME> |
error, jr-a auth switch --profile develop-okta |
jr-a auth switch --profile <PROFILE> <NAME> |
--help is the canonical form ([OPTIONS] <NAME>), but neither error path prints it. The
first error drops [OPTIONS] entirely — implying switch takes no flags at all. The second
promotes --profile out of [OPTIONS] into a required-looking position. So depending on
which one you happen to see, you conclude either "no options are accepted" or "--profile is
mandatory," and both conclusions are wrong.
Consistently echoing the --help signature on error paths would have made this a non-issue.
Why it's confusing
--profile is documented globally as:
--profile <PROFILE> Override the active profile (precedence: this flag > JR_PROFILE > config > "default")
and auth switch is documented as:
Set the default profile in config.toml
Arguments:
<NAME> Profile name to make active. Must already exist in config
For every other subcommand, --profile selecting the profile to act as makes sense. For
auth switch, whose entire purpose is to set the active profile, "override the active
profile" is at best a no-op and at worst reads as the argument you're supposed to use. Two
different ways to name a profile in one command, one of which is silently ignored.
Suggested fix
For the duplicated flag, any of these removes the ambiguity:
- Hide or reject the global
--profile on auth switch (clap hide = true, or a
conflicts_with so it errors with "use the positional NAME instead").
- Accept
--profile as an alias for the positional, so both forms do the same thing.
- Keep it, but make the error explicit — e.g. "
auth switch sets the profile via a
positional NAME; --profile has no effect here."
Option 1 seems cleanest, since --profile genuinely has no meaning for this subcommand.
For the usage/help mismatch: print the same signature everywhere, matching --help. If the
error usage is being derived from the parsed-so-far argument state rather than from the
command definition, that's the thing to fix — a usage string that changes based on what the
user just typed can't be used to learn the correct syntax.
Version
Summary
Two related problems on
auth switch:<NAME>, but the global--profileflag is also accepted — thosemean nearly the same thing, and the invocation that finally works passes the same profile
name twice.
--helpand the error-path usage strings don't agree. The same command reports threedifferent signatures depending on how you invoke it, so there's no single authoritative
answer to "what is the correct syntax?"
What happened
Trying to make
develop-oktathe active profile:That usage line reads as though
--profile <PROFILE>is a required part ofswitch. So theobvious next guess is that the name is also a flag:
Still the same usage line. Eventually this worked:
…which is the same value supplied twice. Meanwhile the bare form was correct all along:
The usage strings and
--helpdisagreeThis is the part that made the above unsolvable by reading. The same subcommand advertises
three different signatures:
jr-a auth switch --helpjr-a auth switch [OPTIONS] <NAME>jr-a auth switchjr-a auth switch <NAME>jr-a auth switch --profile develop-oktajr-a auth switch --profile <PROFILE> <NAME>--helpis the canonical form ([OPTIONS] <NAME>), but neither error path prints it. Thefirst error drops
[OPTIONS]entirely — implyingswitchtakes no flags at all. The secondpromotes
--profileout of[OPTIONS]into a required-looking position. So depending onwhich one you happen to see, you conclude either "no options are accepted" or "
--profileismandatory," and both conclusions are wrong.
Consistently echoing the
--helpsignature on error paths would have made this a non-issue.Why it's confusing
--profileis documented globally as:and
auth switchis documented as:For every other subcommand,
--profileselecting the profile to act as makes sense. Forauth switch, whose entire purpose is to set the active profile, "override the activeprofile" is at best a no-op and at worst reads as the argument you're supposed to use. Two
different ways to name a profile in one command, one of which is silently ignored.
Suggested fix
For the duplicated flag, any of these removes the ambiguity:
--profileonauth switch(claphide = true, or aconflicts_withso it errors with "use the positional NAME instead").--profileas an alias for the positional, so both forms do the same thing.auth switchsets the profile via apositional NAME;
--profilehas no effect here."Option 1 seems cleanest, since
--profilegenuinely has no meaning for this subcommand.For the usage/help mismatch: print the same signature everywhere, matching
--help. If theerror usage is being derived from the parsed-so-far argument state rather than from the
command definition, that's the thing to fix — a usage string that changes based on what the
user just typed can't be used to learn the correct syntax.
Version