Skip to main content

Minimal CLI framework to build Python commands quickly and elegantly.

Project description

CliFire Logo CliFire

CI Status Coverage Status PyPI version License

Minimal CLI framework to build Python commands quickly and elegantly.

CliFire is a lightweight Python library designed to simplify the creation of command-line interfaces (CLI). It allows developers to define commands, options, and arguments in a straightforward way, making it easy to build complex CLI applications without the overhead of bigger frameworks.

Key Features

  • Two Usage Styles: Define commands using decorators or classes.
  • Intuitive Syntax: Focus on writing application logic without worrying about CLI infrastructure.
  • Arguments & Options: Flexible parsing with positional arguments and command options.
  • Grouped Commands: Organize related commands using a dot-based naming convention.
  • Formatted Output: Leverage the Rich library for colorful and styled messages.
  • Templates: Generate files using Jinja2 templates.
  • Centralized Configuration: Manage configuration via YAML using the Config module.

Installation

Install CliFire using pip:

pip install clifire

Or with Poetry:

poetry add clifire

Or with rye:

rye add clifire

Quick Start

Create a simple CLI command using decorators. For example, save the following as fire/hello.py:

from clifire import command, out

@command.fire
def hello(cmd, user: str = "", _sudo: bool = False):
    """
    Display a greeting on the console.

    Args:
        user: Name of the user to greet. If empty, the current system user is used.
        _sudo: Run the command with sudo privileges.
    """
    if not user:
        sudo = 'sudo' if _sudo else ''
        user = cmd.app.shell(f"{sudo} whoami").stdout
    out.info(f'Hi {user}!')

Then run:

fire hello Rob

In action: Demo

For more details, see our Quick Start Guide.

Documentation

The full documentation is available on GitHub Pages in English and Spanish. It covers topics such as:

Development

CliFire is an open-source project, and contributions are welcome! If you find a bug, have a feature request, or want to contribute improvements, please open an issue or submit a pull request.

For development, we use Rye, a Python environment and dependency manager. Rye makes it easy to install dependencies and manage virtual environments. If you don't have it installed, you can follow the instructions on their website.

curl -sSf https://rye.astral.sh/get | bash

To contribute to CliFire:

  1. Fork the repository on GitHub.

  2. Clone your fork locally:

    git clone https://github.com/<your-username>/clifire.git
    cd clifire
    
  3. Create a new branch for your feature or bug fix:

    git checkout -b feature/my-feature
    
  4. Install development dependencies: If you are using Rye, you can install the development dependencies with:

    rye install --with dev
    
  5. Run tests to ensure everything works:

    rye run pytest
    # or to check coverage:
    rye run coverage run -m pytest && rye run coverage html
    

    You can also use the fire coverage command to run the tests and generate the coverage report:

    rye run fire coverage
    
  6. Update the CHANGELOG.md with your changes.

  7. Commit and push your changes, and then create a pull request.

For further contribution details, please see our Contributing Guide.

License

CliFire is released under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clifire-0.1.11.tar.gz (75.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

clifire-0.1.11-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file clifire-0.1.11.tar.gz.

File metadata

  • Download URL: clifire-0.1.11.tar.gz
  • Upload date:
  • Size: 75.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.9

File hashes

Hashes for clifire-0.1.11.tar.gz
Algorithm Hash digest
SHA256 803bebbde5a876bd4f00fe0c58c7bd1a561c3fbe0ffc5b2307ba0dcd923443dd
MD5 9c66ba0e32469682669e5a15e809cb6c
BLAKE2b-256 3b6e87b9adf85a7f932bfd53ea5eccb650e4e1881969a4d062351c3f037617e7

See more details on using hashes here.

File details

Details for the file clifire-0.1.11-py3-none-any.whl.

File metadata

  • Download URL: clifire-0.1.11-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.9

File hashes

Hashes for clifire-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 abf94b1a2f9d7975db2aef4ef71e57a2678761d758e90e808ec7ecf7e2782578
MD5 8663e12dcab20ee8b466e46e05ef9bc0
BLAKE2b-256 e899b7c5101e9bde1a5782084172468049b198759f0ff401ac69e9bc74b23a9b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page