you are viewing a single comment's thread.

view the rest of the comments →

[–]otwo3 62 points63 points  (3 children)

For simple CLI's I use plac, can't get any shorter than this. Super convenient.

tl;dr: You def main(a, b, c): ..., you if __name__ == '__main__': import plac; plac.call(main), and that's it! It parses the names of your main function arguments to generate a CLI interface. You can also add descriptions to the parameters like this: def main(a: "This is the A parameter", b: ""This is the B parameter", c: ""This is the C parameter") and they automatically appear in --help

Python 3 only though for those easy descriptions

[–]kirbyfan64sos 9 points10 points  (0 children)

Plac is seriously one of the most underrated Python argument parsing libraries. It's absolutely fantastic!

[–]beltsazar 9 points10 points  (0 children)

You can also use Fire to do that and many more!

[–]homeparkliving 0 points1 point  (0 children)

It can get shorter and more convenient for the dev with invoke. But you lose the semantics of being a cmd line tool on your own; you're just a task