Skip to main content

Minimal CLI framework to build Python commands quickly and elegantly.

Project description

CliFire Logo CliFire

pre-commit Status Test 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

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

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

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:
    poetry install --with dev
    
  5. Run tests to ensure everything works:
    poetry run pytest
    # or to check coverage:
    poetry run coverage run -m pytest && poetry run coverage html
    
  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.3.tar.gz (12.4 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.3-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: clifire-0.1.3.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.7 Linux/6.11.0-26-generic

File hashes

Hashes for clifire-0.1.3.tar.gz
Algorithm Hash digest
SHA256 449749874a0f665c8cd481692de6967f9d9190fa07de7ecbc6d4f2473fd233ba
MD5 318ce5c43f6289cc00bd32ee4bd6037a
BLAKE2b-256 494e8d458fc2cd1581c97d0c7d6cb83d71e164709c87bffc868920d395cc91ba

See more details on using hashes here.

File details

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

File metadata

  • Download URL: clifire-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.7 Linux/6.11.0-26-generic

File hashes

Hashes for clifire-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6be43969398068288367eb1c471905b4e0f1dd9b41e0b39b2ece6f6c6b000689
MD5 1bdee7d49c0b288372dc69c0d4156868
BLAKE2b-256 5bd7369d9bda5b38b822ca11fc9466bc14e1b0d8e927f9fbbb1f109868735f28

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