Open ghost opened 1 year ago
"pygbag" is a shortcut generated by pip installer, the canonical way to run is python3 -m pygbag
and that one seems to send correct error message, at least on linux. I never really had time to test on win/mac, so feel free to implement, test and PR. Patches and documentation are very welcome especially for win/mac.
@pmp-p - Hello Paul,
I'll first do a bit of research and learning on CLI tools and how pygbag
works before jumping into a PR. I have absolutely no experience with Python CLI tools and how pip
really works 😅.
Based on what you've told me, I assume this is a problem with pygbag
and not pip
generating the shortcut incorrectly, correct?
i think pygbag is lacking a detection mechanism when len(sys.argv) is == 0 That situation may happen when calling it via pip entry point ( not really a shortcut, it is a tiny python program generated by pip in the path).
@pmp-p - Thanks, that helps a ton! 😄
Might make a PR...
Looks like this can be solved with some code in line 17 in ./pygbag/__main__.py
. Maybe this would work:
if len(sys.argv) == 0:
print("...")
raise SystemExit(0)
@pmp-p - I'm not sure how you're printing the help or support message. Is it just a massive string or something else...?
Is it just a massive string or something else
it's a list of all what precedently failed, when that list is non-zero the program halts and report
If I may, the way to call documentation is also slightly frustrating. I wasn't expecting --help
to require folder as an argument.
--help is relative to current project target, it may change in the future based on projects templates.
pygbag roots in posix, usage and help are different things.
usage is not currently implemented on entry point script feel free to PR.
python -m pygbag
-> usage is quite ok
python -m pygbag --help project/main.py
-> help for project with specific paths.
pygbag
-> usage is indeed missing.
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: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.