Replies: 1 comment 1 reply
-
This can be done by using Add these parameters to your I took your code from another discussion thread and added these arguments. fruit_arg = parser_show_fruit.add_argument('fruit', choices_provider=fruit_completer, metavar='ID', descriptive_header='',
help="enter a fruit ID or 'all'", nargs=argparse.OPTIONAL, default='all') |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Let's say I have a
'show fruit'
command with a completer that produces this when I tab:I want to be able to type
'show fruit [ENTER]'
instead of'show fruit all [ENTER]'
. If I just type'show fruit'
with no argument, it should assume 'all'. So basically I want ID to be an optional argument. In my subcommand processing function, I can check whether ID is present [1, 2, 3,...] or None, and if None, I treat it as 'all'I have read the docs but can't quite figure out how to do that.
With the code I have, if they just type
'show fruit [ENTER]'
they get a message:Beta Was this translation helpful? Give feedback.
All reactions