"Unrecognized arguments" in CLI Example
jacohend opened this issue · comments
From the example in the 'confidant help' command, this:
confidant get_service -u "https://confidant-production.example.com" -k "alias/authnz-production" --from myservice-production --to confidant-production --user_type service --region us-west-2 --service myservice-production
yields the error
confidant: error: unrecognized arguments: -u https://confidant-production.example.com -k alias/authnz-production --from myservice-production --to confidant-production --user_type service --region us-west-2
It should yield a url unreachable or kms auth error, not an argument error if the example is correct.
It also appears that the arg usage is incorrect for user_type
(there should be a hyphen, not an underscore):
usage: confidant [-h] [--config-files CONFIG_FILES] [--profile PROFILE] [-u URL] [--retries RETRIES] [-k AUTH_KEY] [-l TOKEN_LIFETIME] [--token-version TOKEN_VERSION] [--from _FROM] [--to _TO] [--user-type USER_TYPE] [--mfa] [--assume-role ASSUME_ROLE] [--region REGION] [--log-level LOG_LEVEL] [--version]
Ah. yeah. The example is bad. I'll make a PR for a correct example. Writing python CLIs is kind of a pain. So, Some of the options are global options and some are specific to the subcommand. Easiest way to know which are which:
global arguments:
confidant --help
subcommand specific arguments:
confidant get_service --help
Here's the call I usually use for get_service:
confidant --profile production get_service --service myservice-production
And here's an example of a confidant client config file that would match that call:
production:
url: https://confidant-production.example.com
auth_key: alias/authnz-production
auth_context:
from: myservice-production
to: confidant-production
user_type: service
token_cache_file: '/run/confidant/token_cache'
region: us-west-2
Ah, ok. Also, it appears that the example actually needs to have the main get_service command moved to after the auth arguments, like so
confidant -u "https://confidant-production.example.com" -k "alias/authnz-production" --from myservice-production --to confidant-production --user_type service --region us-west-2 get_service --service myservice-production
Yep, everything prior to get_service
is a global argument. What you have there looks correct, though user_type
should be user-type
.
I'm gonna keep this open until I fix the example in the code.