
Python Fire: a library for automatically generating command line interfaces - nafizh
https://opensource.googleblog.com/2017/03/python-fire-command-line.html?m=1
======
Groxx
Convenient. I especially like that it has a completion-helper.

The docs seem to go to great lengths to _not_ state this clearly, but it works
fine on bare functions too:

    
    
      example.py:
        import fire
    
        def test(a="yes"):
          print "a: " + a
    
        fire.Fire(test)
    
      cli:
        $ python example.py
        a: yes
        $ python example.py no
        a: no
        $ python example.py --a maybe
        a: maybe

------
wink
I wonder whose problems this solves.

I have a handful of scripts with miniscule CLI handling (usually len(sys.argv)
is enough) - so it's 3 loc instead of 5?

Then I have a moderate amount of scripts where using click or optparse makes
sense. Just looked up one tool, there's exactly 12 lines (including import,
ignoring linebreaks) to handle 6 different CLI args. I could use fire. Less
code, more "magic", less self-documenting excplicit code

Then there's this application with 15 @click.option() lines (don't ask, ran
out of sensible single-char argument shorthands). Yes, it has an ugly main()
with 15 keyword arguments, but I'd also have that with fire I guess. but here
at least it's explicit again.

TLDR: Sounds absolutely nice on first skim, but I don't see why I would ever
use this. Have I been writing so many CLI apps in python already that I
exhibit stockholm syndrome towards click AND optparse? :)

~~~
BerislavLopac
I've lately come to know and respect argparse. Click is nice and great, but
can present an unnecessary burden if your script uses (intentionally or not)
no other dependencies outside the standard library. And optparse is deprecated
in Python 3.

~~~
wink
Oh yes, I'm strictly a Python 2 user (I know, I know).

------
jsmeaton
Some libraries just seem obvious in retrospect. This looks very cool. I've had
a lot of success using click for command line programs in the past. Fire looks
like it'd replace click for the majority of simple cli programs I write.

------
rajathagasthya
Looks pretty good. But if you're going to open source it, you might as well
make it a proper Python project and conform to style guides (Google's own for
one). This one has all the tests in the same directory as other files instead
of a 'tests' directory, it's missing requirements.txt and method names start
with upper case.

------
scrollaway
Looks great! Very intuitive. This is something I could actually see myself
using instead of argparse; and being able to generate a CLI from a third party
object is amazing!

------
empath75
Looks fantastic. Argparse isn't hard to use, but it's a lot of boilerplate.
I'll be happy not to have to deal with it again.

~~~
BrandoElFollito
You may want to give a try to docopt

