YARU (やる)
Write and manage your project's development scripts with modern Python syntax.
The project's name comes from the Japanese verb やる, which means "to do".
Highlights
- 🗂️ Lightweight package with zero dependencies.
- 🐍 Supports modern Python versions (>=3.12).
- 🚀 Simply write your development scripts as Python functions.
- 🖥️ Supports macOS, Linux, and Windows.
Installation
If using the uv package manager:
uv add --dev yaru
If using pip:
pip install yaru
Documentation
Yaru's documentation is available at https://github.com/c0dearm/yaru.
Features
A single decorator to rule them all
Simply decorate your Python functions to convert them into cli commands:
# :commands.py file
from typing import Annotated
from yaru import Arg, Context, command
# Add two numbers
@command
def add_numbers(c: Context, a: int, b: int) -> None:
"""Given `a` and `b`, print the sum of both numbers to stdout."""
print(a + b)
The decorated functions must be discovered by yaru, so they need to be in a module named commands at
the root of your project, for example a commands.py file.
The add_numbers command is now invokable through the cli, this is the output of yaru --help:
usage: yaru [-h] {add-numbers} ...
Project's development commands
positional arguments:
{add-numbers}
add-numbers Add two numbers
options:
-h, --help show this help message and exit
For specific help on the command usage, you can do: yaru add-numbers --help:
usage: yaru add-numbers [-h] a b
Given `a` and `b`, print the sum of both numbers to stdout.
positional arguments:
a
b
options:
-h, --help show this help message and exit
Running the command yaru add-numbers 42 69 in your terminal will output 111.
Automated command metadata
The help text for the cli command is automatically parsed from the comments immiediatelly preceding the decorated function. Similarly, the command's description is obtained from the function's docstrings.
Moreover, you can use annotated type hints on your function's arguments in order to add help texts to the command's parameters too:
# :commands.py file
from typing import Annotated
from yaru import Arg, Context, command
# Add two numbers
@command
def add_numbers(
c: Context,
a: Annotated[int, Arg(help="First operand")],
b: Annotated[int, Arg(help="Second operand")],
) -> None:
"""Given `a` and `b`, print the sum of both numbers to stdout."""
print(a + b)
The add-numbers cli help will now display as:
usage: yaru add-numbers [-h] a b
Given `a` and `b`, print the sum of both numbers to stdout.
positional arguments:
a First operand
b Second operand
options:
-h, --help show this help message and exit
Optional arguments
If you define the function's arguments as optional (keyword arguments with defaults), yaru will treat
them as such in the cli. For example:
# :commands.py file
from yaru import Context, command
@command
def say_something(c: Context, phrase: str, twice: bool = False) -> None:
print(phrase)
if twice:
print(phrase)
Will be handled like this:
usage: yaru say-something [-h] [--twice | --no-twice] phrase
positional arguments:
phrase
options:
-h, --help show this help message and exit
--twice, --no-twice
Context to run commands in a shell
You may have noticed an extra first Context argument in all the commands. This is automatically injected
by yaru and provides a handy method run to execute instructions in your shell.
Going back to the example of number addition, we could do this in bash instead of python:
# :commands.py file
from yaru import Context, command
# Add two numbers
@command
def add_numbers(c: Context, a: int, b: int) -> None:
c.run(f"echo $(({a} + {b}))")
The behavior when executed is exactly the same.
Contributing
We welcome contributions! Please read our CONTRIBUTING.md file for guidelines on how to contribute to this project.
Acknowledgements
Yaru exists thanks to pyinvoke, which was the main inspirer.
License
Yaru is licensed under the MIT license (LICENSE or https://opensource.org/licenses/MIT)
Metadata
Release files for yaru 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| yaru-0.2.0.tar.gz | 24.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| yaru-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 33.5 kB
Release files / yaru-0.2.0.tar.gz
| Download URL | yaru-0.2.0.tar.gz |
|---|---|
| Size | 24.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6d5404d976a33d87c27daad878f781273efb723b9719230877854e300dae6738
|
|
BLAKE2b-256 checksum How to use checksums |
fa41c7897972e96c34cfa720844870adbb6355512313f77899396b4dd9353084
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 22, 2025.
Transparency logRelease files / yaru-0.2.0-py3-none-any.whl
| Download URL | yaru-0.2.0-py3-none-any.whl |
|---|---|
| Size | 9.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2fc331cb2079b11fc2aaedd56c4669dd439fd12fb775dee3a2951b15bb448255
|
|
BLAKE2b-256 checksum How to use checksums |
353e4e5113670756e627bee1e25bd3e84f63d99bda33be63283cd3ca49c86484
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 22, 2025.
Transparency log