Python Fire

0.7.1 · active · verified Sun Apr 05

Python Fire is a library for automatically generating command-line interfaces (CLIs) from any Python object. It enables developers to turn functions, classes, objects, and dictionaries into CLIs with minimal code, simplifying the creation of powerful command-line tools. The current version is 0.7.1, with a consistent release cadence focusing on compatibility, feature enhancements, and bug fixes.

Warnings

Install

Imports

Quickstart

Define a Python function or class, then pass it to `fire.Fire()` within your script. When executed, Fire automatically creates a CLI from the object. You can run this example as `python your_script.py --name David --enthusiasm 3` or `python your_script.py --help`.

import fire

def greet(name='World', enthusiasm=1):
  """Greets the given name with specified enthusiasm."""
  return f"Hello {name}{'!' * enthusiasm}"

if __name__ == '__main__':
  fire.Fire(greet)

view raw JSON →