404
+ +Page not found
+ + +diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 8be46672..00000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,31 +0,0 @@ -# Basic dependabot.yml file with minimum configuration for two package managers - -version: 2 -updates: - # Enable version updates for python - - package-ecosystem: "pip" - directory: "/" - schedule: - interval: "monthly" - labels: ["dependabot"] - pull-request-branch-name: - separator: "-" - open-pull-requests-limit: 5 - reviewers: - - "dbieber" - - # Enable version updates for GitHub Actions - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "monthly" - groups: - gh-actions: - patterns: - - "*" # Check all dependencies - labels: ["dependabot"] - pull-request-branch-name: - separator: "-" - open-pull-requests-limit: 5 - reviewers: - - "dbieber" diff --git a/.github/scripts/build.sh b/.github/scripts/build.sh deleted file mode 100755 index d9207dfe..00000000 --- a/.github/scripts/build.sh +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (C) 2018 Google Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#!/usr/bin/env bash - -# Exit when any command fails. -set -e - -PYTHON_VERSION=${PYTHON_VERSION:-3.7} - -pip install -e .[test] -python -m pytest # Run the tests without IPython. -pip install ipython -python -m pytest # Now run the tests with IPython. -pylint fire --ignore=test_components_py3.py,parser_fuzz_test.py,console -if [[ ${PYTHON_VERSION} == 3.12 ]]; then - # Run type-checking - pip install ty - python -m ty check --python $(which python) --exclude fire/test_components_py3.py --exclude fire/console/ --exclude fire/formatting_windows.py -fi diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 6b9d1eae..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Python Fire - -on: - push: - branches: ["master"] - pull_request: - branches: ["master"] - -defaults: - run: - shell: bash - -jobs: - build: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: ["macos-latest", "ubuntu-latest"] - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14.0-rc.2"] - include: - - {os: "ubuntu-22.04", python-version: "3.7"} - - steps: - # Checkout the repo. - - name: Checkout Python Fire repository - uses: actions/checkout@v4 - - # Set up Python environment. - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - # Build Python Fire using the build.sh script. - - name: Run build script - run: ./.github/scripts/build.sh - env: - PYTHON_VERSION: ${{ matrix.python-version }} diff --git a/.gitignore b/.gitignore deleted file mode 100644 index a2166684..00000000 --- a/.gitignore +++ /dev/null @@ -1,103 +0,0 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -env/ -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -*.egg-info/ -.installed.cfg -*.egg - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*,cover -.hypothesis/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# pyenv -.python-version - -# celery beat schedule file -celerybeat-schedule - -# SageMath parsed files -*.sage.py - -# dotenv -.env - -# virtualenv -.venv -venv/ -ENV/ - -# Spyder project settings -.spyderproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# PyCharm IDE -.idea/ - -# Type-checking -.pytype/ diff --git a/examples/__init__.py b/.nojekyll similarity index 100% rename from examples/__init__.py rename to .nojekyll diff --git a/404.html b/404.html new file mode 100644 index 00000000..fbece880 --- /dev/null +++ b/404.html @@ -0,0 +1,129 @@ + + +
+ + + + +Page not found
+ + +| Setup | +Command | +Notes | +
|---|---|---|
| install | +pip install fire |
+Installs fire from pypi | +
| 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 | +command --help |
+Show the help screen. | +
| REPL | +command -- --interactive |
+Enters interactive mode. | +
| Separator | +command -- --separator=X |
+This sets the separator to X. The default separator is -. |
+
| Completion | +command -- --completion [shell] |
+Generate a completion script for the CLI. | +
| Trace | +command -- --trace |
+Gets a Fire trace for the command. | +
| Verbose | +command -- --verbose |
++ |
Note that flags are separated from the Fire command by an isolated -- arg.
+Help is an exception; the isolated -- is optional for getting help.
| Argument | +Usage | +Notes | +
|---|---|---|
| component | +fire.Fire(component) |
+If omitted, defaults to a dict of all locals and globals. | +
| command | +fire.Fire(command='hello --name=5') |
+Either a string or a list of arguments. If a string is provided, it is split to determine the arguments. If a list or tuple is provided, they are the arguments. If command is omitted, then sys.argv[1:] (the arguments from the command line) are used by default. |
+
| name | +fire.Fire(name='tool') |
+The name of the CLI, ideally the name users will enter to run the CLI. This name will be used in the CLI's help screens. If the argument is omitted, it will be inferred automatically. | +
| serialize | +fire.Fire(serialize=custom_serializer) |
+If omitted, simple types are serialized via their builtin str method, and any objects that define a custom __str__ method are serialized with that. If specified, all objects are serialized to text via the provided method. |
+
You can use Python Fire on a module without modifying the code of the module. +The syntax for this is:
+python -m fire <module> <arguments>
or
+python -m fire <filepath> <arguments>
For example, python -m fire calendar -h will treat the built in calendar
+module as a CLI and provide its help.
It's dead simple. Simply write the functionality you want exposed at the command +line as a function / module / class, and then call Fire. With this addition of a +single-line call to Fire, your CLI is ready to go.
+ +When you're writing a Python library, you probably want to try it out as you go. +You could write a main method to check the functionality you're interested in, +but then you have to change the main method with every new experiment you're +interested in testing, and constantly updating the main method is a hassle. +You could also open an IPython REPL and import your library there and test it, +but then you have to deal with reloading your imports every time you change +something.
+If you simply call Fire in your library, then you can run all of it's
+functionality from the command line without having to keep making changes to
+a main method. And if you use the --interactive flag to enter an IPython REPL
+then you don't need to load the imports or create your variables; they'll
+already be ready for use as soon as you start the REPL.
You can take an existing module, maybe even one that you don't have access to
+the source code for, and call Fire on it. This lets you easily see what
+functionality this code exposes, without you having to read through all the
+code.
This technique can be a very simple way to create very powerful CLIs. Call
+Fire on the difflib library and you get a powerful diffing tool. Call Fire
+on the Python Imaging Library (PIL) module and you get a powerful image
+manipulation command line tool, very similar in nature to ImageMagick.
The auto-generated help strings that Fire provides when you run a Fire CLI +allow you to see all the functionality these modules provide in a concise +manner.
+ +Using Fire lets you call Python directly from Bash. So you can mix your Python
+functions with the unix tools you know and love, like grep, xargs, wc,
+etc.
Additionally since writing CLIs in Python requires only a single call to Fire, +it is now easy to write even one-off scripts that would previously have been in +Bash, in Python.
+ +When you use the --interactive flag to enter an IPython REPL, it starts with
+variables and modules already defined for you. You don't need to waste time
+importing the modules you care about or defining the variables you're going to
+use, since Fire has already done so for you.