Questions tagged [python-fire]

a library for automatically generating command line interfaces (CLIs) from any Python object

Python Fire (PyPI package fire) is a library for automatically generating command line interfaces (CLIs) "from absolutely any Python object".

15 questions
12
votes
6 answers

How to pass a list/array as argument to python fire?

I have function like this - def my_func(my_list_arg=["one", "two"]): Which I'm trying to call from command line using python-fire. I have tried several ways - Attempt 1: fire_runner.py my_func [one, two] Results in two separate arguments "[one"…
Duke79
  • 827
  • 1
  • 10
  • 21
4
votes
0 answers

Combine python fire with dataclass

I have a code like below with multiple functions inside for various calculations. I am using python fire to pass arguments instead of defining argparse and call the functions from cli. Every time I add a new parameter I have to add self for it in…
4
votes
2 answers

Python Fire hyphen vs underscore

The python package Fire is very useful for launching python scripts from command line. One common thing is to have arguments made of multiple words, for instance name of cat that can be written in 3 commons way…
Statistic Dean
  • 4,861
  • 7
  • 22
  • 46
2
votes
1 answer

google fire run @property automatically

I use google fire for cli, and met an issue below. # test.py import fire class C: @property def foo(self): print('foo') def bar(self): print('bar') fire.Fire() then run as python test.py C bar foo bar as seen it…
Felix Liu
  • 199
  • 2
  • 9
2
votes
0 answers

Passing array with single member with python fire module

I have a function like this: def test_readout(self, nr_triggers=10, dump_data=False, lanes=range(9)): Which is to be called by command line using the fire python module, via a master file called testbench.py. I want to set the parameter lanes to an…
GrixM
  • 215
  • 2
  • 4
  • 20
1
vote
1 answer

How to customize the default help text for the command line python-fire by google?

I am trying to make a small command line tool using python-fire module by google. My filename is my_tools.py. Inside my_tools.py I have code class MainFunction(): def __init__(self): self.config = WrapperConfig() def hey_world(self): …
1
vote
2 answers

Command line interface for python module

I'm not sure what to search for this. I am writing a piece of code using python fire to create a command line interface. python test.py function argument is there a way to make the shell interpret the following like the command above: test function…
1
vote
2 answers

Using multiple flags for same argument of a function fired through python-fire

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…
1
vote
2 answers

Why do I always get type info printed when using python fire?

I have a simple test python-fire cli program in python 2.7.15 import fire class Math: def add(x, y): """add""" return x + y def multiply(x, y): """multiply""" return x * y if __name__ == '__main__': …
bradgonesurfing
  • 30,949
  • 17
  • 114
  • 217
1
vote
1 answer

Python Fire doesn't parse single argument with whitespaces correctly

I have a function like this - def f(arg) print(arg) trying to pass an argument with Python Fire like this - f hello there output - hello
0
votes
1 answer

Python Fire module not showing COMMANDS in `-h`

I am using the python Fire module with an abstract parent class and a child class. Not all functions are abstract, some functions do not need to be replicated for each child: parent class from abc import ABC, abstractmethod class Foo(ABC): …
bcsta
  • 1,963
  • 3
  • 22
  • 61
0
votes
2 answers

Pass arguments to command groups, python fire

How can I pass the arguments val and code to the group get Code so far import fire class Get: def __init__(self, val="no", code=""): self.val = val self.code = code def get(self): return f"called get…
basic mojo
  • 128
  • 2
  • 12
0
votes
1 answer

How can I use default arguments in a method with python-fire?

I am having an issue with python-fire when a method has arguments with default values. Consider the following code: import fire class SomeClass(object): def __init__(self): self.a = '' self.b = '' def methoda(self): …
securisec
  • 3,435
  • 6
  • 36
  • 63
0
votes
2 answers

Suppress output to show only Usage and Docstring

I would like to suppress the output when using python-fire, for a given command line option. The fire trace and everything apart from the docstring and usage is essentially useless to me and clutters up the terminal. Any way I can get rid of it…
Utkarsh K
  • 1
  • 2
-2
votes
1 answer

Passing a list into one kwargs

The final idea is to start my python program with a command like : python.exe -m myProgram execute --tags arg1 arg2 arg3 I'm trying to get "arg_1", "arg_2", ..., "arg_n" (with n unknown) inside a list and access all of them thanks to "tags" I tried…
NickNick
  • 223
  • 1
  • 10