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

Gooey with Click https://github.com/mitsuhiko/click ? #135

Closed
pombredanne opened this issue Dec 15, 2015 · 13 comments
Closed

Gooey with Click https://github.com/mitsuhiko/click ? #135

pombredanne opened this issue Dec 15, 2015 · 13 comments

Comments

@pombredanne
Copy link

How hard would it be to have Gooey work with Click https://github.com/mitsuhiko/click a popular CLI framework by @mitsuhiko maker of Flask among other super goodies?

Note that Click uses neither argparse nor optparse but should provide introspection capabilities.

@chriskiehl
Copy link
Owner

@pombredanne That the first I've ever heard of Click. The composable decorator approach it takes is pretty interesting. According to the docs, its internals are actually a fork of optparse, which in turn has similar conventions to argparse (e.g. types, dests, metavars, etc..), so.. I imagine it wouldn't be too difficult.

@pombredanne
Copy link
Author

@chriskiehl I use it in a few project after having used optparse, argparse, baker, docopt, cliff and several other and I find it working better for me.

For instance here: https://github.com/nexB/scancode-toolkit/blob/a967fc768f8f9c39e066982eb5015fcf3b2952d5/src/scancode/cli.py#L235

I am not all alone there. See some of the hits here https://github.com/search?l=python&q=import+click+command&ref=searchresults&type=Code&utf8=%E2%9C%93 and there https://pypi.python.org/pypi?%3Aaction=search&term=%22Click+%22&submit=search

I cannot say I blindly use any code from pocoo and @mitsuhiko but code from this provenance definitely has been working for me and is usually not too shaby... and way better than anything I can write :)

Now, what would be the best approach? I do not think parsing the Python sources would make sense with Click. If so where would you plug that in?

@chriskiehl
Copy link
Owner

Gooey doesn't really parse anything. It uses good ol' fashion introspection.

Being that the internals are forked from optparse, I'd wager that the method would be quite the same as the one for argparse: monkey patch its parse_args() equivalent, and then pump its attributes over to Gooey.

However, having only skimmed the docs, that would be my best uninformed guess at a starting point.

@pombredanne
Copy link
Author

@chriskiehl commented 17 hours ago

Gooey doesn't really parse anything. It uses good ol' fashion introspection.

I thought that you were parsing source code based on this:

def parse_source_file(file_name):

@chriskiehl
Copy link
Owner

Ha! Yeah, I neglected to say anymore : ) It doesn't parse anything... anymore. Gooey originally grew out of me messing around with the ast, so there is certainly some vestigial parsing code in there. But now it just patches the parse_args call and gets everything that way.

I have a branch sitting locally that finally cleans up all the cruft, but.. alas.. time.

@yoavram
Copy link

yoavram commented Jan 24, 2016

👍

@jackandjackadswithsm
Copy link

I am also using Click package and appreciate any update on this..any roadmap??

@mgaitan
Copy link

mgaitan commented Apr 25, 2017

IMHO the best way to go is making gooey supports https://github.com/wooey/clinto spec to build interfaces, and build extra parsers on that project.

related to wooey/clinto#12

@pombredanne
Copy link
Author

@mgaitan do wooey and gooey use the same input from clinto?

@mgaitan
Copy link

mgaitan commented Apr 27, 2017

@pombredanne not currently. would be a great idea IMHO

@bittner
Copy link

bittner commented Apr 27, 2018

Note that there is QUICK for click, a project inspired by Gooey.

@chriskiehl
Copy link
Owner

Closing. No plans to implement at the moment.

Community patches are always welcome, though!

@raphaelsetin
Copy link

My comment on this other issue may be of help if you want to run a CLI mode without having to pass extra flags, and also with the ability to customize the CLI handler isolated from Gooey.

My use case was to define a GUI function using Gooey and a CLI function using Click; both were defined in separate functions. I know it's not the most convenient way of handling this, but it's the only way of customizing the CLI mode isolated from the GUI mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants