1

I am using google python-fire library for cli automation.

I have a function, say inside code.py :

def foo(input_path='some default value'):
    doing something...

def main():
    fire.Fire(foo)

Now I can use $ python code.py foo --input-path 'somepath'

But now I want to add shorthand -i too for the same task. How can I achieve this ?

Pranav Gupta
  • 651
  • 9
  • 14

2 Answers2

0

CLI generated by python-fire is based totally on arguments names defined in function signature.

After a bit of research I found this issue . This PR essentially adds this functionality but the current version released on pypi or conda does not include this feature. It is going to be added in next release.

Currently one can use the first letter of you argument in shorthand notation only for bool types. Also note that fire raises conflict error in case of multiple flags starting with same first letter (if one uses shorthand notation).

Pranav Gupta
  • 651
  • 9
  • 14
0

The use of short-flags when they are unambiguous has been introduced in the latest version, fire v0.2.0.

If you upgrade to the latest version, you'll be able to use the shorthand -i as desired. Use pip install -U fire to upgrade.