Open

Description
Machine:
macOS 12.6.5
Python 3.11.3
Pip 22.0.x (I'm not sure what the "x" is...)
Problem:
When calling the pygbag
command in a terminal without any arguments, you get the following error:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.11/bin/pygbag", line 8, in <module>
sys.exit(main())
^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pygbag/app.py", line 479, in main
asyncio.run(main_run(app_folder, mainscript))
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pygbag/app.py", line 174, in main_run
parser = argparse.ArgumentParser()
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/argparse.py", line 1760, in __init__
prog = _os.path.basename(_sys.argv[0])
~~~~~~~~~^^^
This is because the code tries to find an argument (with indices) when none are given, thus an IndexError
is raised.
Solution (suggestion):
Instead of throwing an ugly, long error, just give the user the "help" message. I've seen this done in other CL tools. When I ran the command pygbag
, I expected a help message. Logically, this makes sense as if the user is new to the tool, and runs the comand without any flags or arguments, maybe they are confused, or don't know the tool works. Thus, a help message would, well, be helpful.