Python Fire is a library that turns functions, classes, modules, and other Python objects into command-line interfaces automatically.
Overview
Python Fire is a Google library for automatically generating command line interfaces from almost any Python object. You can call Fire on functions, classes, modules, objects, dictionaries, lists, tuples, and similar types.
It offers a simple way to create a CLI in Python, and can help with developing, debugging, and exploring code. It also supports turning existing code into a CLI and easing movement between Bash and Python.
Installation is available via pip or conda. Basic usage is `fire.Fire()` on a component so that component becomes a Fire CLI. The CLI supports help flags, interactive REPL mode, custom separators, shell completion scripts, tracing, and verbosity options separated by an isolated `--`.
Python Fire is not an official Google product. It is useful when you want a quick CLI around Python callables without writing argparse boilerplate.
Key features
- CLI from any Python object
- pip and conda install
- Interactive REPL mode
- Shell completion generation
- Help and trace flags
- Works on functions and classes
- Custom argument separators
- Module-level Fire CLIs
Use cases
- Quick Python CLIs
- Debugging Python code
- Exploring unfamiliar codebases
- Bash and Python workflows
- REPL with pre-imported modules