Hi. I've been working on a decorator that generates a command-line interface for a function based on its signature. Have a look and tell me what you think!
https://github.com/ninjaaron/lazycli
(Nov-06-2018, 05:48 PM)ninjaaron Wrote: [ -> ]Have a look and tell me what you think!
Frankly speaking, there are now many modules that wrap argparse to provide a simplified API to generate command-line interfaces. So the question is what does
lazycli
have that other systems don't? It doesn't appear to be fundamentally simpler than
argh
or
click
for example.
I recently started using
plumbum.cli. I like its approach of subcommands which makes them full-fledged cli applications that can be easily separated from the main application. It is an achievement in terms of modularity.
(Nov-06-2018, 06:24 PM)micseydel Wrote: [ -> ]Looks cool!
I'm glad you like it!
(Nov-06-2018, 06:32 PM)Gribouillis Wrote: [ -> ] (Nov-06-2018, 05:48 PM)ninjaaron Wrote: [ -> ]Have a look and tell me what you think!
Frankly speaking, there are now many modules that wrap argparse to provide a simplified API to generate command-line interfaces. So the question is what does lazycli
have that other systems don't? It doesn't appear to be fundamentally simpler than argh
or click
for example.
I recently started using plumbum.cli. I like its approach of subcommands which makes them full-fledged cli applications that can be easily separated from the main application. It is an achievement in terms of modularity.
Thanks for taking a look! The difference between
lazycli
and
click
is pretty big!
click
is extremely full-featured and composable. However, each argument is its own function decorator, so there is a lot more boiler-plate than
lazycli
. (also, click is NOT an argparse wrapper. It wraps optparse.)
argh
looks very similar to
lazycli
, in the basic usecase. I've never seen it before, but I might not have written lazycli if I'd known about it! There are two main differences that I can see:
argh
exposes all the power of argparse and offers several usage patterns, though it does a good job at keeping the simplest usecase simple. Very much what I was going for. lazycli offers only the one decorator as its interface and intentionally only supports relatively simple usecases. It's not designed to compete with something like click
or docopt
.
lazycli
does type inference (and, to that end, looks at type annotations), which allows it to generate some minimal documentation of parameters automatically, and also means that you have to do less parsing of arguments inside your script. Inferred types are used as constructors.
The main goal of lazycli is to do as much as possible by looking at the function signature and save the programmer from having to think about their CLI. It's aimed especially at prototyping, where you want to focus on code more than interface, but you need just a little more than what
sys.argv
is giving you.
argh
would fit the same usecase well.
I really like the interface of
plumbum.cli
that you posted, also. Looks great for more involved interfaces.
Just to mention
python-fire when it comes to quick CLI interfaces. Didn't use it but also look simple and quick and doing a lot instead of you.
(Nov-07-2018, 08:58 AM)buran Wrote: [ -> ]Just to mention python-fire when it comes to quick CLI interfaces. Didn't use it but also look simple and quick and doing a lot instead of you.
Thanks for the info. It looks pretty cool, but it also looks a little... hm... magical. But it does look easy to use.