$ show google/python-fire
Python Fire is a library for automatically generating command-line interfaces (CLIs) from any Python object. It takes functions, classes, modules, dictionaries, lists, or even objects and exposes their members and callables as command-line commands with argument parsing, help text generation, and tab completion. The core architecture is a single package (`fire`) with entry points `fire.Fire()` and `python -m fire`. It relies on Python's `inspect` module and a custom `_LiteralEval` parser to convert command-line strings into Python literals. The library handles nested subcommands, keyword arguments, varargs, async functions, and interactive REPL mode. It is well-tested with over 30 test files and supports Python 3.7 through 3.14.
The LLM identified 2 files worth highlighting for reuse:
A standalone docstring parser that extracts summary, description, arguments, returns, yields, and raises sections from Google, NumPy, and RST formatted docstrings. It is self-contained with no internal fire dependencies, using only standard library modules. This component can be extracted and reused in any Python project that needs to parse structured information from docstrings, demonstrating careful handling of whitespace, indentation, and multiple docstring conventions.
Provides the default argument parsing function `DefaultParseValue` that converts command-line strings into Python values using a custom `_LiteralEval`. This function extends `ast.literal_eval` to treat bare words as strings (enabling YAML-like syntax such as `{key: value}`) while preserving numeric, boolean, and None literals. It handles quoted strings, lists, dicts, tuples, and nested containers. Though tied to Fire's argument model, the core parsing logic could be reused in other CLI frameworks needing flexible input parsing.