Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conquer the land of arguing snakes #788

Closed
Prev Previous commit
Next Next commit
fixup! Add CLI to run any Python program based on argparse
  • Loading branch information
pawamoy committed Feb 8, 2022
commit 2694a78dbe7fc561a65e0284c0441abff1385430
4 changes: 4 additions & 0 deletions gooey/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@
def main(args=None):
args = args or sys.argv[1:]
if not args:
# without args we assume we want to run gooey on gooey itself
# TODO: rewrite using argparse
Copy link
Author

@pawamoy pawamoy Feb 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running Gooey on itself requires rewriting this function with an argparse parser. Let me know if this is something you'd like 🙂

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave it up to you ^_^

I'd be fine going sans additional configuration for the initial release of this -- let it "bake" a bit and see if people need the functionality. On the flip side, if you want to throw a parser in there so people can control things that's fine, too. You may be able to even generate a options for all of the params directly from the type definition by looking through its __annotations__ (in theory).

script_name = "gooey"
else:
script_name = args[0]
scripts = {script.name: script for script in entry_points().get('console_scripts')}
if script_name in scripts:
# a valid script was passed
script = scripts[script_name]
module_path = script.module
function_name = script.attr
prog = script_name
elif ':' in script_name:
# the path to a function was passed
module_path, function_name = args[0].split(':')
prog = module_path.split('.', 1)[0]
pawamoy marked this conversation as resolved.
Show resolved Hide resolved
if len(args) > 1:
Expand Down