google / python-fire

Python Fire is a library for automatically generating command line interfaces (CLIs) from absolutely any Python object.
Other
26.95k stars 1.44k forks source link

How to pass '2e9672320848' as a str value? #507

Closed jump2cn closed 5 months ago

jump2cn commented 6 months ago
import fire

def test(value: str = None):
    print('got value:', value)

if __name__ == '__main__':
    fire.Fire({
        'test': test
    })

> python test.py test "2e9672320848"
< got value: inf
dbieber commented 5 months ago

One option is: python test.py test '"2e9672320848"'

Another option is to decorate your function with @fire.decorators.SetParseFn(str)