{"library":"fire","title":"Python Fire","description":"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.","status":"active","version":"0.7.1","language":"en","source_language":"en","source_url":"https://github.com/google/python-fire","tags":["cli","command-line-interface","tool","automation","development"],"install":[{"cmd":"pip install fire","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"Fire is the primary entry point for generating CLIs.","symbol":"Fire","correct":"from fire import Fire"}],"quickstart":{"code":"import fire\n\ndef greet(name='World', enthusiasm=1):\n  \"\"\"Greets the given name with specified enthusiasm.\"\"\"\n  return f\"Hello {name}{'!' * enthusiasm}\"\n\nif __name__ == '__main__':\n  fire.Fire(greet)","lang":"python","description":"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`."},"warnings":[{"fix":"Upgrade your project to Python 3, or pin `fire` to a version less than 0.7.0 (e.g., `pip install 'fire<0.7.0'`).","message":"Python Fire dropped support for Python 2 starting with version 0.7.0. If your project relies on Python 2, you must use an older version of the library.","severity":"breaking","affected_versions":">=0.7.0"},{"fix":"Ensure you are using `fire` version `0.1.3` or newer. This issue was resolved in that release.","message":"Arguments passed to a Fire-generated CLI that start with `--` (e.g., `--my-flag`) might not have been correctly interpreted as strings in very old versions of Fire. This could lead to unexpected parsing errors.","severity":"gotcha","affected_versions":"<0.1.3"},{"fix":"For an executable script, include `if __name__ == '__main__': fire.Fire(your_object)`. To interact with an arbitrary module, use the command line form: `python -m fire os.path` to expose the `os.path` module as a CLI.","message":"While `fire.Fire()` is typically called directly within a script, you can also use `python -m fire <module_name>` or `python -m fire <path_to_file.py>` to generate a CLI for an existing module or file without modifying its source code. This is useful for exploring or interacting with third-party libraries.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-05T00:00:00.000Z","next_check":"2026-07-04T00:00:00.000Z"}