About this project
Python Fire is a library for automatically generating command line interfaces (CLIs) from absolutely any Python object. It provides a simple way to create CLIs, aids in developing and debugging Python code, helps explore existing code or turn other people's code into a CLI, eases transitioning between Bash and Python, and simplifies using a Python REPL by pre-importing modules and variables.
Installation can be done via pip (`pip install fire`), conda (`conda install fire -c conda-forge`), or from source by cloning the repository and running `python setup.py install`.
Basic usage involves calling `Fire` on any Python object—functions, classes, modules, objects, dictionaries, lists, tuples, etc. For example, calling `fire.Fire(hello)` on a function allows running `python hello.py --name=David` from the command line. Calling `fire.Fire(Calculator)` on a class enables commands like `python calculator.py double 10`.
The library supports various flags for enhanced functionality, including `--help` for usage information, `-- --interactive` for interactive mode, `-- --separator=X` to set a custom separator, `-- --completion [shell]` to generate completion scripts, `-- --trace` for debugging traces, and `-- --verbose` for verbose output. These flags are separated from the Fire command by an isolated `--`.
Python Fire is licensed under Apache 2.0 and is not an official Google product.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.