fire


Namefire JSON
Version 0.7.1 PyPI version JSON
download
home_pageNone
SummaryA library for automatically generating command line interfaces.
upload_time2025-08-16 20:20:24
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseApache-2.0
keywords command line interface cli python fire interactive bash tool
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python Fire [![PyPI](https://img.shields.io/pypi/pyversions/fire.svg?style=plastic)](https://github.com/google/python-fire)

_Python Fire is a library for automatically generating command line interfaces
(CLIs) from absolutely any Python object._

-   Python Fire is a simple way to create a CLI in Python.
    [[1]](docs/benefits.md#simple-cli)
-   Python Fire is a helpful tool for developing and debugging Python code.
    [[2]](docs/benefits.md#debugging)
-   Python Fire helps with exploring existing code or turning other people's
    code into a CLI. [[3]](docs/benefits.md#exploring)
-   Python Fire makes transitioning between Bash and Python easier.
    [[4]](docs/benefits.md#bash)
-   Python Fire makes using a Python REPL easier by setting up the REPL with the
    modules and variables you'll need already imported and created.
    [[5]](docs/benefits.md#repl)

## Installation

To install Python Fire with pip, run: `pip install fire`

To install Python Fire with conda, run: `conda install fire -c conda-forge`

To install Python Fire from source, first clone the repository and then run:
`python setup.py install`

## Basic Usage

You can call `Fire` on any Python object:<br>
functions, classes, modules, objects, dictionaries, lists, tuples, etc.
They all work!

Here's an example of calling Fire on a function.

```python
import fire

def hello(name="World"):
  return "Hello %s!" % name

if __name__ == '__main__':
  fire.Fire(hello)
```

Then, from the command line, you can run:

```bash
python hello.py  # Hello World!
python hello.py --name=David  # Hello David!
python hello.py --help  # Shows usage information.
```

Here's an example of calling Fire on a class.

```python
import fire

class Calculator(object):
  """A simple calculator class."""

  def double(self, number):
    return 2 * number

if __name__ == '__main__':
  fire.Fire(Calculator)
```

Then, from the command line, you can run:

```bash
python calculator.py double 10  # 20
python calculator.py double --number=15  # 30
```

To learn how Fire behaves on functions, objects, dicts, lists, etc, and to learn
about Fire's other features, see the [Using a Fire CLI page](docs/using-cli.md).

For additional examples, see [The Python Fire Guide](docs/guide.md).

## Why is it called Fire?

When you call `Fire`, it fires off (executes) your command.

## Where can I learn more?

Please see [The Python Fire Guide](docs/guide.md).

## Reference

| Setup   | Command             | Notes
| :------ | :------------------ | :---------
| install | `pip install fire`  |

| Creating a CLI | Command                | Notes
| :--------------| :--------------------- | :---------
| import         | `import fire`          |
| Call           | `fire.Fire()`          | Turns the current module into a Fire CLI.
| Call           | `fire.Fire(component)` | Turns `component` into a Fire CLI.

| Using a CLI                                     | Command                                 | Notes
| :---------------------------------------------- | :-------------------------------------- | :----
| [Help](docs/using-cli.md#help-flag)             | `command --help` or `command -- --help` |
| [REPL](docs/using-cli.md#interactive-flag)      | `command -- --interactive`              | Enters interactive mode.
| [Separator](docs/using-cli.md#separator-flag)   | `command -- --separator=X`              | Sets the separator to `X`. The default separator is `-`.
| [Completion](docs/using-cli.md#completion-flag) | `command -- --completion [shell]`       | Generates a completion script for the CLI.
| [Trace](docs/using-cli.md#trace-flag)           | `command -- --trace`                    | Gets a Fire trace for the command.
| [Verbose](docs/using-cli.md#verbose-flag)       | `command -- --verbose`                  |

_Note that these flags are separated from the Fire command by an isolated `--`._

## License

Licensed under the
[Apache 2.0](https://github.com/google/python-fire/blob/master/LICENSE) License.

## Disclaimer

This is not an official Google product.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "fire",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "command, line, interface, cli, python, fire, interactive, bash, tool",
    "author": null,
    "author_email": "David Bieber <david810+fire@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/c0/00/f8d10588d2019d6d6452653def1ee807353b21983db48550318424b5ff18/fire-0.7.1.tar.gz",
    "platform": null,
    "description": "# Python Fire [![PyPI](https://img.shields.io/pypi/pyversions/fire.svg?style=plastic)](https://github.com/google/python-fire)\n\n_Python Fire is a library for automatically generating command line interfaces\n(CLIs) from absolutely any Python object._\n\n-   Python Fire is a simple way to create a CLI in Python.\n    [[1]](docs/benefits.md#simple-cli)\n-   Python Fire is a helpful tool for developing and debugging Python code.\n    [[2]](docs/benefits.md#debugging)\n-   Python Fire helps with exploring existing code or turning other people's\n    code into a CLI. [[3]](docs/benefits.md#exploring)\n-   Python Fire makes transitioning between Bash and Python easier.\n    [[4]](docs/benefits.md#bash)\n-   Python Fire makes using a Python REPL easier by setting up the REPL with the\n    modules and variables you'll need already imported and created.\n    [[5]](docs/benefits.md#repl)\n\n## Installation\n\nTo install Python Fire with pip, run: `pip install fire`\n\nTo install Python Fire with conda, run: `conda install fire -c conda-forge`\n\nTo install Python Fire from source, first clone the repository and then run:\n`python setup.py install`\n\n## Basic Usage\n\nYou can call `Fire` on any Python object:<br>\nfunctions, classes, modules, objects, dictionaries, lists, tuples, etc.\nThey all work!\n\nHere's an example of calling Fire on a function.\n\n```python\nimport fire\n\ndef hello(name=\"World\"):\n  return \"Hello %s!\" % name\n\nif __name__ == '__main__':\n  fire.Fire(hello)\n```\n\nThen, from the command line, you can run:\n\n```bash\npython hello.py  # Hello World!\npython hello.py --name=David  # Hello David!\npython hello.py --help  # Shows usage information.\n```\n\nHere's an example of calling Fire on a class.\n\n```python\nimport fire\n\nclass Calculator(object):\n  \"\"\"A simple calculator class.\"\"\"\n\n  def double(self, number):\n    return 2 * number\n\nif __name__ == '__main__':\n  fire.Fire(Calculator)\n```\n\nThen, from the command line, you can run:\n\n```bash\npython calculator.py double 10  # 20\npython calculator.py double --number=15  # 30\n```\n\nTo learn how Fire behaves on functions, objects, dicts, lists, etc, and to learn\nabout Fire's other features, see the [Using a Fire CLI page](docs/using-cli.md).\n\nFor additional examples, see [The Python Fire Guide](docs/guide.md).\n\n## Why is it called Fire?\n\nWhen you call `Fire`, it fires off (executes) your command.\n\n## Where can I learn more?\n\nPlease see [The Python Fire Guide](docs/guide.md).\n\n## Reference\n\n| Setup   | Command             | Notes\n| :------ | :------------------ | :---------\n| install | `pip install fire`  |\n\n| Creating a CLI | Command                | Notes\n| :--------------| :--------------------- | :---------\n| import         | `import fire`          |\n| Call           | `fire.Fire()`          | Turns the current module into a Fire CLI.\n| Call           | `fire.Fire(component)` | Turns `component` into a Fire CLI.\n\n| Using a CLI                                     | Command                                 | Notes\n| :---------------------------------------------- | :-------------------------------------- | :----\n| [Help](docs/using-cli.md#help-flag)             | `command --help` or `command -- --help` |\n| [REPL](docs/using-cli.md#interactive-flag)      | `command -- --interactive`              | Enters interactive mode.\n| [Separator](docs/using-cli.md#separator-flag)   | `command -- --separator=X`              | Sets the separator to `X`. The default separator is `-`.\n| [Completion](docs/using-cli.md#completion-flag) | `command -- --completion [shell]`       | Generates a completion script for the CLI.\n| [Trace](docs/using-cli.md#trace-flag)           | `command -- --trace`                    | Gets a Fire trace for the command.\n| [Verbose](docs/using-cli.md#verbose-flag)       | `command -- --verbose`                  |\n\n_Note that these flags are separated from the Fire command by an isolated `--`._\n\n## License\n\nLicensed under the\n[Apache 2.0](https://github.com/google/python-fire/blob/master/LICENSE) License.\n\n## Disclaimer\n\nThis is not an official Google product.\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "A library for automatically generating command line interfaces.",
    "version": "0.7.1",
    "project_urls": {
        "Homepage": "https://github.com/google/python-fire",
        "Repository": "https://github.com/google/python-fire"
    },
    "split_keywords": [
        "command",
        " line",
        " interface",
        " cli",
        " python",
        " fire",
        " interactive",
        " bash",
        " tool"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e54c93d0f85318da65923e4b91c1c2ff03d8a458cbefebe3bc612a6693c7906d",
                "md5": "af5b01507b592c9bd4e525497399af5d",
                "sha256": "e43fd8a5033a9001e7e2973bab96070694b9f12f2e0ecf96d4683971b5ab1882"
            },
            "downloads": -1,
            "filename": "fire-0.7.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "af5b01507b592c9bd4e525497399af5d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 115945,
            "upload_time": "2025-08-16T20:20:22",
            "upload_time_iso_8601": "2025-08-16T20:20:22.870710Z",
            "url": "https://files.pythonhosted.org/packages/e5/4c/93d0f85318da65923e4b91c1c2ff03d8a458cbefebe3bc612a6693c7906d/fire-0.7.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "c000f8d10588d2019d6d6452653def1ee807353b21983db48550318424b5ff18",
                "md5": "182fc2764d8e891964ae3ad2861102dd",
                "sha256": "3b208f05c736de98fb343310d090dcc4d8c78b2a89ea4f32b837c586270a9cbf"
            },
            "downloads": -1,
            "filename": "fire-0.7.1.tar.gz",
            "has_sig": false,
            "md5_digest": "182fc2764d8e891964ae3ad2861102dd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 88720,
            "upload_time": "2025-08-16T20:20:24",
            "upload_time_iso_8601": "2025-08-16T20:20:24.175242Z",
            "url": "https://files.pythonhosted.org/packages/c0/00/f8d10588d2019d6d6452653def1ee807353b21983db48550318424b5ff18/fire-0.7.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-16 20:20:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "google",
    "github_project": "python-fire",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "fire"
}
        
Elapsed time: 1.66266s