Python package for creating command-line interfaces in a pythonic way.
Project description
clipy
clipy is a Python package for creating command-line interfaces (CLIs) in a pythonic way. Its core philosophy is that a command shouldn't be as different from a Python function.
The key features are:
- Pythonic API: The functions and class definitions are the commands and groups.
- Easy to use: It's easy to create CLIs with automatic help generation and argument casting.
- Support complex CLIs: You can create complex applications with deeply nested commands, variable number of arguments, and more.
- End user friendly: Given wrong input, it will point out the exact location of the error like a compiler would do.
Quickstart
Install:
pip install clipyx
A simple example:
import clipy
@clipy.Command
def greeting(name: str):
"""
Greeting the provided name
Args:
name: The name to greet
"""
print(f"Hello There!\nGeneral {name}!")
if __name__ == "__main__":
greeting()
Then enjoy your CLI:
python greeting.py --help
# usage: greeting [--name <str>]
# Greeting the provided name
# options:
# --name NAME:str The name to greet
# --help Show this help message and exit.
python greeting.py --name=Kenobi
# Hello There!
# General Kenobi!
python greeting.py Kenobi
# Hello There!
# General Kenobi!
python greeting.py --not-an-arg
# usage: greeting [--name <str>]
# command:
# $ greeting --not-an-arg
# ^^^^^^^^^^^^
# greeting: error: unknown argument: --not-an-arg
Supported Python versions: 3.9 and above.
For more complex examples, like automatic casting, nested commands, variable number of arguments, and more, check the examples folder.
Installation
clipy is available on PyPI, you can install it using pip:
pip install clipyx
Otherwise, you can install a specific version from GitHub:
pip install git+https://github.com/G-Lauz/clipy.git@v1.0.0
Or clone the repository and install it manually:
git clone https://github.com/G-Lauz/clipy.git
cd clipy
pip install .
Why clipy?
There are already many CLI libraries in Python, such as argparse, Click, Typer, and more. So why do we need another one?
The goal here isn't to replace them, but provide an alternative that emphasizes a different design philosophy. clipy is designed to be as close to regular Python code as possible, making it easy to learn and use. You should use clipy when you want to focus on the logic of your application rather than the CLI framework.
Roadmap
- Support configuration files as arguments (e.g.
json,yaml, etc.). - Support short and combined short options (e.g.
-hfor--helpand-abc). - Support a wider range of argument types (e.g.
pathlib.Path,enum, etc.). - See the issue tracker for more details and to contribute.
Contributing
Contributions are welcome! If you have any ideas, suggestions, or bug reports, please open an issue or submit a pull request on GitHub.
Please read the CONTRIBUTING.md to help you get started.
License
This project is licensed 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
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 clipyx-1.0.0.tar.gz.
File metadata
- Download URL: clipyx-1.0.0.tar.gz
- Upload date:
- Size: 19.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b33eca6b0fa6aabc227c0c7756ee8510abf2f2b823f862fc5efaf4d368bde77
|
|
| MD5 |
6eb7412e731ceb5416d0c664048986a7
|
|
| BLAKE2b-256 |
c7f5ffed54f12080cbcdfab798de64ed027b621c5b2569213ef7d5dc55e427dc
|
Provenance
The following attestation bundles were made for clipyx-1.0.0.tar.gz:
Publisher:
publish.yml on G-Lauz/clipy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clipyx-1.0.0.tar.gz -
Subject digest:
2b33eca6b0fa6aabc227c0c7756ee8510abf2f2b823f862fc5efaf4d368bde77 - Sigstore transparency entry: 1883643758
- Sigstore integration time:
-
Permalink:
G-Lauz/clipy@0b0c54b0b9893759216fe55593c3af1ef280d84c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/G-Lauz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0b0c54b0b9893759216fe55593c3af1ef280d84c -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file clipyx-1.0.0-py3-none-any.whl.
File metadata
- Download URL: clipyx-1.0.0-py3-none-any.whl
- Upload date:
- Size: 21.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a107f142db29ebb7644c6f1c40fa1058d731d7a79be8ef66fd5ccbf60c6a064d
|
|
| MD5 |
8e78a50423842a9ac285af96855c2077
|
|
| BLAKE2b-256 |
68f653f3f91d4925ea4fcdb1884b47a696ac218cc71f4feab6c81be8c9d55f11
|
Provenance
The following attestation bundles were made for clipyx-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on G-Lauz/clipy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clipyx-1.0.0-py3-none-any.whl -
Subject digest:
a107f142db29ebb7644c6f1c40fa1058d731d7a79be8ef66fd5ccbf60c6a064d - Sigstore transparency entry: 1883643918
- Sigstore integration time:
-
Permalink:
G-Lauz/clipy@0b0c54b0b9893759216fe55593c3af1ef280d84c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/G-Lauz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0b0c54b0b9893759216fe55593c3af1ef280d84c -
Trigger Event:
workflow_dispatch
-
Statement type: