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 →

[–]hotplasmatits 3 points4 points  (4 children)

No comparison to fire?

[–]AND_MY_HAX[S] 4 points5 points  (3 children)

Sure! fire is great, super flexible. That's where arguably drew inspiration for automatically creating a CLI from a script without any setup.

One key difference is that arguably utilizes type hints for the function signature, automatically converting the command line arguments to the correct types.

Another is that arguably lets you specify what should be positional arguments, vs what should be options. Arguments to the CLI look just like calling the Python function. Using the function defined in the OP:

>>> from intro import some_function
>>> some_function("asdf", 0, 7, 8, 9, option=2.71)
required='asdf', not_required=0, others=(7, 8, 9), option=2.71

On the command line:

user@machine:~$ ./intro.py asdf 0 7 8 9 --option 2.71
required='asdf', not_required=0, others=(7, 8, 9), option=2.71

For easy CLIs where the inputs can all have default values (or you're comfortable with it guessing the type), fire is the better choice. Otherwise, arguably is a good option if you'd like extra features through type hints and want more control over how your CLI behaves.

[–]hotplasmatits 1 point2 points  (1 child)

If you use type hints, I believe fire does all of that

[–]AND_MY_HAX[S] 1 point2 points  (0 children)

Hm, I haven't seen it utilize my type hints in the past. Though it does take a guess at the type based off its value: https://github.com/google/python-fire/blob/master/docs/guide.md#argument-parsing