Skip to main content

Python package for creating command-line interfaces in a pythonic way.

Project description

pre-commit Linting: pylint

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. -h for --help and -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

clipyx-1.0.0.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

clipyx-1.0.0-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

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

Hashes for clipyx-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2b33eca6b0fa6aabc227c0c7756ee8510abf2f2b823f862fc5efaf4d368bde77
MD5 6eb7412e731ceb5416d0c664048986a7
BLAKE2b-256 c7f5ffed54f12080cbcdfab798de64ed027b621c5b2569213ef7d5dc55e427dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for clipyx-1.0.0.tar.gz:

Publisher: publish.yml on G-Lauz/clipy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for clipyx-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a107f142db29ebb7644c6f1c40fa1058d731d7a79be8ef66fd5ccbf60c6a064d
MD5 8e78a50423842a9ac285af96855c2077
BLAKE2b-256 68f653f3f91d4925ea4fcdb1884b47a696ac218cc71f4feab6c81be8c9d55f11

See more details on using hashes here.

Provenance

The following attestation bundles were made for clipyx-1.0.0-py3-none-any.whl:

Publisher: publish.yml on G-Lauz/clipy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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