Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 51 additions & 30 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on: [push, pull_request]
jobs:
pre-commit:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -26,45 +25,67 @@ jobs:

- name: Install dependencies
run: |
rye pin cpython@3.12.2
rye sync --all-features

- name: Run pre-commit
run: rye run pre-commit run --all-files

test:
test-python-3_8:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Set up Python for Rye
uses: actions/setup-python@v4
with:
python-version: '3.12'

- name: Install Rye
run: |
curl -sSf https://rye.astral.sh/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_TOOLCHAIN_VERSION: '3.12'
RYE_VERSION: '0.44.0'
RYE_INSTALL_OPTION: '--yes'
- name: Install Rye
run: |
curl -sSf https://rye.astral.sh/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_INSTALL_OPTION: '--yes'

- name: Install dependencies
run: |
rye sync --all-features
- name: Install dependencies
run: |
rye pin cpython@3.8.2
rye sync --all-features

- name: Run unit tests
run: rye run coverage run -m pytest
- name: Run unit tests
run: rye run fire tests

- name: Generate coverage report
run: rye run coverage xml
test-python-3_12:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Upload coverage to Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: |
pip install coveralls
coveralls
- name: Set up Python for Rye
uses: actions/setup-python@v4
with:
python-version: '3.12'

- name: Install Rye
run: |
curl -sSf https://rye.astral.sh/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_INSTALL_OPTION: '--yes'

- name: Install dependencies
run: |
rye pin cpython@3.12.2
rye sync --all-features

- name: Run unit tests with coverage
run: rye run fire coverage

- name: Upload coverage to Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: |
pip install coveralls
coveralls
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ __pycache__/
.Python
build/
dist/
poetry.lock

# Coverage
htmlcov/
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ repos:
hooks:
- id: pyupgrade
name: Automatically upgrade syntax for newer versions of the language
args: ["--py310-plus", "--keep-runtime-typing", "--keep-percent-format"]
args: ["--py38-plus", "--keep-runtime-typing", "--keep-percent-format"]

- repo: local
hooks:
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.7
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
## [0.1.8] - 2025-07-07

### Added
- Handle program interruption with `KeyboardInterrupt` to allow canceling the execution of a command.
- Added an `icon` argument to the `critical`, `error`, `warning`, and `success` methods in `out` to display an icon.
- Added the same `icon` argument to the `error`, `warning`, and `success` methods of `live`.
- Added a Dockerfile to test the library with Python 3.8.

### Changed
- Minimum Python version is now 3.10.
- Minimum Python version is now 3.6.
- Set the Python version for development to 3.12.7.
- Removed package versions in `pyproject.toml` to use the latest versions.

### Fixed
- Change poetry to rye in the scripts for building and testing the package.
- Changed poetry to rye in the scripts for building and testing the package.

## [0.1.7] - 2025-07-06

Expand Down
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM ubuntu:latest
ARG PYTHON_VERSION=3.8.2

RUN apt-get update && apt-get install -y \
curl \
&& rm -rf /var/lib/apt/lists/*

ENV RYE_HOME="/root/.rye"
ENV RYE_INSTALL_OPTION="--yes"
ENV RYE_NO_AUTO_INSTALL="true"
RUN curl -sSf https://rye.astral.sh/get | bash
ENV PATH="/root/.rye/shims:${PATH}"

WORKDIR /app
COPY pyproject.toml README.md ./
COPY src ./src
COPY tests ./tests
COPY fire ./fire

RUN rye pin cpython@${PYTHON_VERSION} && \
rye sync --all-features

CMD ["rye", "run", "fire", "tests"]
6 changes: 3 additions & 3 deletions docs/docs/en/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ There are several ways you can help:
#### **Run the Tests:**
Make sure all tests pass using:
```bash
poetry run pytest
rye run pytest
```
Check the coverage with:
```bash
poetry run coverage run -m pytest && poetry run coverage html
rye run coverage run -m pytest && rye run coverage html
```

You can also use `poetry run fire coverage` to run the tests and generate the coverage report.
You can also use `rye run fire coverage` to run the tests and generate the coverage report.

#### **Submit a Pull Request:**
Once you are satisfied with your changes, submit a *pull request* to the main branch of the repository. Describe in detail what you have changed and the motivation behind it.
Expand Down
6 changes: 6 additions & 0 deletions docs/docs/en/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ pip install clifire
poetry add clifire
```

### Using Rye

```bash
rye add clifire
```

## Basic Usage

CliFire allows you to define commands using decorators or classes. Here’s an example using a decorator to greet the user:
Expand Down
8 changes: 4 additions & 4 deletions docs/docs/en/user-guide/output.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ Below are the most commonly used functions:
out.var_dump(sample_dict)
```

- **`out.LiveText`**
This is a class that allows you to update text in real time in the terminal. It is useful for displaying progress bars or counters that update dynamically.
- **`out.live`**
This is a method that allows you to update text in real time in the terminal. It is useful for displaying progress bars or counters that update dynamically.
```python
live_text = out.LiveText("Starting...")
live_text = out.live("Starting...")
live_text.info("Process running")
live_text.warn("Retrying operation")
live_text.success("Operation completed", end=False)
Expand Down Expand Up @@ -100,7 +100,7 @@ class OutCommand(command.Command):
print('')
print('Live text')
print('-' * 80)
live_text = out.LiveText("Starting...")
live_text = out.live("Starting...")
time.sleep(1)
live_text.info("Process running")
time.sleep(1)
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/es/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ Existen varias maneras de ayudar:
#### **Ejecuta los tests:**
Asegúrate de que todos los tests pasan con:
```bash
poetry run pytest
rye run pytest
```
Comprueba la cobertura:
```bash
poetry run coverage run -m pytest && poetry run coverage html
rye run coverage run -m pytest && rye run coverage html
```

También puedes usar `poetry run fire coverage` para ejecutar los tests y generar el informe de cobertura.
También puedes usar `rye run fire coverage` para ejecutar los tests y generar el informe de cobertura.

#### **Realiza un Pull Request:**
Una vez que estés satisfecho con tus cambios, realiza un *pull request* a la rama principal del repositorio. Describe detalladamente lo que has cambiado y la motivación detrás de ello.
Expand Down
6 changes: 6 additions & 0 deletions docs/docs/es/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ pip install clifire
poetry add clifire
```

### Usando Rye

```bash
rye add clifire
```

## Uso Básico

CliFire te permite definir comandos mediante decoradores o clases. Aquí tienes un ejemplo utilizando un decorador para saludar al usuario:
Expand Down
23 changes: 23 additions & 0 deletions fire/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@ def build(cmd):
cmd.app.fire('doc build')


@command.fire
def publish(cmd):
'''
Publish then package
'''
live = out.LiveText('Puiblising ...')
res = cmd.app.shell('rye publish -y', capture_output=False)
if res:
live.success('Published')
else:
live.error('Error on publish package')
return 1


@command.fire
def coverage(cmd):
'''
Expand All @@ -75,3 +89,12 @@ def precommit(cmd):
Launch pre-commit
'''
cmd.app.shell('pre-commit run --all-files', capture_output=False)


@command.fire
def tests(cmd):
'''
Launch tests
'''
path = cmd.app.path(os.path.dirname(__file__), '..')
cmd.app.shell('rye run python -m pytest', capture_output=False, path=path)
32 changes: 32 additions & 0 deletions fire/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from clifire import command


@command.fire
def test_legacy(cmd, _build: bool = False, python_version: str = '3.8.2'):
'''
Launch tests in docker image with specified Python version

Args:
python_version: Python version to use for the tests. (default: '3.8.2')
_build: Force build the Docker image before running tests.
'''

image_name = f'clifire-py{python_version}'

def docker_build():
cmd.app.shell(
f'docker build --build-arg PYTHON_VERSION={python_version} '
f'-t {image_name} .',
capture_output=False,
)

if _build:
docker_build()
elif image_name not in cmd.app.shell('docker images').stdout:
docker_build()

volumen_str = '-v ./src:/app/src -v ./tests:/app/tests'
cmd.app.shell(
f'docker run --rm {volumen_str} {image_name}',
capture_output=False,
)
22 changes: 11 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ authors = [
]
packages = ["src"]
readme = "README.md"
requires-python = ">= 3.0"
requires-python = ">= 3.6"
dependencies = [
"jinja2>=3.1.6",
"pyyaml>=6.0.2",
"rich>=14.0.0",
"jinja2",
"pyyaml",
"rich",
]

[build-system]
Expand All @@ -21,13 +21,13 @@ build-backend = "hatchling.build"
[tool.rye]
managed = true
dev-dependencies = [
"coverage>=7.9.1",
"mkdocs-material>=9.6.14",
"mkdocs-static-i18n>=1.3.0",
"mkdocs>=1.6.1",
"pre-commit>=4.2.0",
"pytest>=8.4.0",
"black-with-tabs>=22.10.0",
"coverage",
"mkdocs-material",
"mkdocs-static-i18n",
"mkdocs",
"pre-commit",
"pytest",
"black-with-tabs",
]

[tool.hatch.metadata]
Expand Down
Loading