Python Forum
lazycli: zero-effort command-line interfaces
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
lazycli: zero-effort command-line interfaces
#1
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
Reply
#2
Looks cool!
Reply
#3
(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.
Reply
#4
(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:

  1. 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.
  2. 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.
Reply
#5
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.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#6
(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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  get any domain's Alexa rank via command line rootVIII 2 3,289 Oct-14-2018, 08:34 PM
Last Post: rootVIII

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020