Python Fire v0.2.0 CLI library upgrades with new improvements
Python Fire turns up with a new update. The latest release, version v0.2.0 adds some new improvements. This library auto-generates command line interfaces (CLI) from any Python object. You can call Fire on Python functions, classes, objects, dicts, or anything else!
Python Fire heats things up with one spicy command:
Fire. This open source library automatically generates command line interfaces from any Python object. It can be used as a tool for developing and debugging by calling Fire in the library.
The latest release arrived on July 26, 2019. Version 0.2.0 improves a few things and makes some tweaks to the library. Let’s fan the flames and see what’s included in the update, as well as some uses and benefits.
Updates and improvements
Version 0.2.0 released with a few new improvements in tow. Take a look at the latest changes:
- Help screens: New cleaner help screen appearances. Help screens appear after encountering a user error.
- Custom serialization: Define a custom
__str__method on an object and it will be used to serialize the object in the final result of a Fire command.
- Docstring parsing: Partial support for three common docstrings: Google, numpy, and REST style.
- Accessing –help: No need to separate –help with an extra –.
- NamedTuples support: Fields of namedtuples objects accessible
- Callable objects: Use flag syntax in order to call a callable object
- Single-hyphen flag support: Use either
- Short-flags now permitted
- Fish completion support
Benefits of Fire
Some of Python Fire’s benefits and uses:
- Call Fire on functions, classes, objects, dicts, or anything else.
- Debugging code: Call Fire in the library and run functionality directly from the command line. No need to load imports.
- Easy Bash transitions: Call Python directly from Bash. Mix and match functions together with familiar Unix tools.
- Fire upon existing modules: Take code from elsewhere and call Fire on it. From GitHub: “Call
Fireon the difflib library and you get a powerful diffing tool. Call
Fireon the Python Imaging Library (PIL) module and you get a powerful image manipulation command line tool, very similar in nature to ImageMagick.”
- Easier Python REPL: Save time by using the
--interactiveflag and start with already defined variables and modules.
Install Python Fire from pypi using pip install fire. Or clone and run the source with python setup.py install.
If Fire doesn’t light up your world, take a look at a few other similar command-line applications.