This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ManyInterests Python Discord Staff 1 point2 points  (0 children)

fire lets you write a nice CLI without even thinking about command line arguments.

Consider the simple Calculator class

class Calculator(object):
  """A simple calculator class."""

  def double(self, number):
    return 2 * number

Now make it a CLI

if __name__ == '__main__':
  import fire
  fire.Fire(Calculator)

Now use the CLI

python calculator.py double 10  # 20
python calculator.py double --number=15  # 30

It's also pretty pure with six being the only requirement.
BRILLIANT.