Python Fire v0.2.0 CLI library upgrades with new improvements

Share
  • July 29, 2019

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:

SEE ALSO: LazyDocker – simple terminal UI aims to make Docker easier

  • 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  -flag and  --flag
  • Short-flags now permitted
  • Fish completion support

Benefits of Fire

Some of Python Fire’s benefits and uses:

SEE ALSO: The Second Age of Agile: measuring success with meaningful Agile metrics

  • 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 Fire on the difflib library and you get a powerful diffing tool. Call Fire on 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 --interactive flag and start with already defined variables and modules.

Read more about its uses on GitHub.

Ready, aim…

Install Python Fire from pypi using pip install fire. Or clone and run the source with python setup.py install.

To get started, the documentation suggests that the easiest way is by calling  fire.Fire() at the end of the program. Check out the full guide and some examples here.

If Fire doesn’t light up your world, take a look at a few other similar command-line applications.

  • Click: Python package that creates CLI with little code.
  • Clize : Python argument parser, an alternative to argparse

The post Python Fire v0.2.0 CLI library upgrades with new improvements appeared first on JAXenter.

Source : JAXenter