multimeric / ArgparsePrompt

Wrapper for the built-in Argparse, allowing missing command-line arguments to be filled in by the user via interactive prompts
GNU General Public License v3.0
11 stars 4 forks source link

Crash when using `action='store_true'` #5

Open Radagaisus opened 4 years ago

Radagaisus commented 4 years ago

Using parser.add_argument('--spectate', default=False, action='store_true') crashes with the following error:

Traceback (most recent call last):
...
  File "/opt/anaconda3/lib/python3.7/site-packages/argparse_prompt.py", line 30, in add_argument
    action = super().add_argument(*args, type=type, default='', **kwargs)
  File "/opt/anaconda3/lib/python3.7/argparse.py", line 1353, in add_argument
    action = action_class(**kwargs)
TypeError: __init__() got an unexpected keyword argument 'type'

Problem is here. Passing a type when it’s not needed will cause Argparse to throw the error.

multimeric commented 4 years ago

This is a bit tricky, since the library requires the type mechanism in order to hook into argparse. I guess I'll have to patch my own version of it somehow.

Radagaisus commented 4 years ago

@TMiguelT Wouldn’t it be easier to just skip flags with this action? False is used by default if they’re not added, True if the flag is present — no real need for a prompt.

multimeric commented 4 years ago

That's missing the point of this lib, though. That's just default argparse behaviour. If you want that, you can just use prompt=False, but eventually I'm going to have to work out how to deal with this properly.

voldemortX commented 2 years ago

Hi guys! What is the status of this problem now?