Minimal CLI framework to build Python commands quickly and elegantly.
Project description
CliFire
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
Configmodule.
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. It covers topics such as:
- CliFire Basics
- Decorators
- Class-based Commands
- Options and Arguments
- Grouped Commands
- Output and Styling
- Configuration
- Templates
- Changelog
- Contributing
Development
To contribute to CliFire:
- Fork the repository on GitHub.
- Clone your fork locally:
git clone https://github.com/<your-username>/clifire.git cd clifire
- Create a new branch for your feature or bug fix:
git checkout -b feature/my-feature
- Install development dependencies:
poetry install --with dev
- Run tests to ensure everything works:
poetry run pytest # or to check coverage: poetry run coverage run -m pytest && poetry run coverage html
- Update the CHANGELOG.md with your changes.
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clifire-0.1.1.tar.gz.
File metadata
- Download URL: clifire-0.1.1.tar.gz
- Upload date:
- Size: 11.7 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fcdf3cc8d437aaa6f217402e5e7a0291a079606e36aba0b004c5ee6ba858586a
|
|
| MD5 |
50a9c2e38a22737d5c19010e763f4f54
|
|
| BLAKE2b-256 |
c63a1bb19017cee0809f5f9d696a922a10418029df4bbc71e83c48308eaa40bf
|
File details
Details for the file clifire-0.1.1-py3-none-any.whl.
File metadata
- Download URL: clifire-0.1.1-py3-none-any.whl
- Upload date:
- Size: 13.3 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe0ef7f6e54eda8cd63fcb5f8ab483b5e9b648b6dde516503d176398adf578f5
|
|
| MD5 |
fb5d52dfa623653b14c7ed22d0a79cce
|
|
| BLAKE2b-256 |
dc8ef48ec010b07134107a1153d85df2a28e66b93f82b37a7fcf4cb8f0478e01
|