All Projects → google → Python Fire

google / Python Fire

Licence: other
Python Fire is a library for automatically generating command line interfaces (CLIs) from absolutely any Python object.

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Labels

Projects that are alternatives of or similar to Python Fire

Js Fire
A javascript clone of google/python-fire 🔥
Stars: ✭ 370 (-98.2%)
Mutual labels:  cli
Go Github Selfupdate
Binary self-update mechanism for Go commands using GitHub
Stars: ✭ 370 (-98.2%)
Mutual labels:  cli
Mongo Seeding
The ultimate solution for populating your MongoDB database.
Stars: ✭ 375 (-98.17%)
Mutual labels:  cli
Sqlite Utils
Python CLI utility and library for manipulating SQLite databases
Stars: ✭ 368 (-98.2%)
Mutual labels:  cli
Cw
The best way to tail AWS CloudWatch Logs from your terminal
Stars: ✭ 368 (-98.2%)
Mutual labels:  cli
Httplab
The interactive web server
Stars: ✭ 3,752 (-81.7%)
Mutual labels:  cli
Apio
🌱 Open source ecosystem for open FPGA boards
Stars: ✭ 366 (-98.21%)
Mutual labels:  cli
Visidata
A terminal spreadsheet multitool for discovering and arranging data
Stars: ✭ 4,606 (-77.53%)
Mutual labels:  cli
Kondo
Save disk space by cleaning non-essential files from software projects.
Stars: ✭ 373 (-98.18%)
Mutual labels:  cli
Abc
Power of appbase.io via CLI, with nifty imports from your favorite data sources
Stars: ✭ 375 (-98.17%)
Mutual labels:  cli
Pick
create curses based interactive selection list in the terminal
Stars: ✭ 370 (-98.2%)
Mutual labels:  cli
Pixo
Convert SVG icons into React components
Stars: ✭ 371 (-98.19%)
Mutual labels:  cli
Superplate
Performance-oriented frontend application creator with popular tools.
Stars: ✭ 368 (-98.2%)
Mutual labels:  cli
Jql
A JSON Query Language CLI tool
Stars: ✭ 368 (-98.2%)
Mutual labels:  cli
Md To Pdf
Hackable CLI tool for converting Markdown files to PDF using Node.js and headless Chrome.
Stars: ✭ 374 (-98.18%)
Mutual labels:  cli
Nba Go
🏀 💻 The finest NBA CLI.
Stars: ✭ 3,634 (-82.27%)
Mutual labels:  cli
Gitlab Time Tracker
🦊🕘 A command line interface for GitLab's time tracking feature.
Stars: ✭ 371 (-98.19%)
Mutual labels:  cli
Ava
Node.js test runner that lets you develop with confidence 🚀
Stars: ✭ 19,458 (-5.08%)
Mutual labels:  cli
Confy
🛋 Zero-boilerplate configuration management in Rust
Stars: ✭ 379 (-98.15%)
Mutual labels:  cli
Npx card
use npx anmol to connect with me
Stars: ✭ 377 (-98.16%)
Mutual labels:  cli

Python Fire PyPI

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]
  • Python Fire is a helpful tool for developing and debugging Python code. [2]
  • Python Fire helps with exploring existing code or turning other people's code into a CLI. [3]
  • Python Fire makes transitioning between Bash and Python easier. [4]
  • 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]

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:
functions, classes, modules, objects, dictionaries, lists, tuples, etc. They all work!

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

import fire

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

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

Then, from the command line, you can run:

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.

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:

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.

For additional examples, see The Python Fire Guide.

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.

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 command --help or command -- --help
REPL command -- --interactive Enters interactive mode.
Separator command -- --separator=X Sets the separator to X. The default separator is -.
Completion command -- --completion [shell] Generates a completion script for the CLI.
Trace command -- --trace Gets a Fire trace for the command.
Verbose command -- --verbose

Note that these flags are separated from the Fire command by an isolated --.

License

Licensed under the Apache 2.0 License.

Disclaimer

This is not an official Google product.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].