Python Fire is a library for automatically generating command line interfaces (CLIs) from absolutely any Python object.
OTHER License
Bot releases are hidden (Show)
This is the last release supporting Python 2. Subsequent releases will be Python 3 only. The automatically generated release notes follow.
Github
-> GitHub
by @jbampton in https://github.com/google/python-fire/pull/425
$
sign in bash completion by @maximehk in https://github.com/google/python-fire/pull/472
Full Changelog: https://github.com/google/python-fire/compare/v0.5.0...v0.6.0
Published by dbieber almost 2 years ago
fire.Fire(serialize=custom_serialize_fn)
#345You can now pass a custom serialization function to fire to control how the output is serialized.
Your serialize function should accept an object as input, and may return a string as output. If it returns a string, Fire will display that string. If it returns None, Fire will display nothing. If it returns something else, Fire will use the default serialization method to convert it to text.
The default serialization remains unchanged from previous versions. Primitives and collections of primitives are serialized one item per line. Objects that define a custom __str__
function are serialized using that. Complex objects that don't define __str__
trigger their help screen rather than being serialized and displayed.
Published by dbieber over 3 years ago
python -m fire
python -m fire
You can use Python Fire without ever modifying your code. To use it, first install Python Fire with pip install fire
. Then simply run python -m fire path/to/yourfile.py
or python -m fire path.to.yourmodule
.
This is both a fast way to use Python Fire to create a CLI from your code, and a way to apply Python Fire quickly to a codebase you don't have access to.
Published by dbieber over 4 years ago
Removes preexec_fn from pager subprocess call. Resolves #236.
Published by dbieber over 4 years ago
python -m fire <module>
Published by dbieber about 5 years ago
Bug fixes
Published by dbieber about 5 years ago
If you're new to Python Fire:
e.g. You can call Fire on a function, as in this example (but you can also call Fire on anything else: classes, objects, dicts, etc. -- they all work.)
def hello(name="World"):
return "Hello %s!" % name
fire.Fire(hello)
hello.py --name=David # Hello David!
pip install fire
to get started.
__str__
method on an object, that will be used to serialize the object when it is the final result of a Fire command. This means better support for numpy arrays, and better support for custom types.command -h
or command --help
will give help, provided there isn't an argument named help
in your component.-flag
instead of --flag
if preferred. Both work.alpha
, then you can specify its value with -a
.Published by dbieber over 6 years ago
This release has a few small improvements:
And a small packaging improvement:
Published by dbieber about 7 years ago
Improvements
command
argument now accepts either a sequence of arguments or a single string.command
argument only accepted a string.Published by dbieber over 7 years ago
New Features
Bug Fixes