Skip to main content

No project description provided

Project description

Platitudes

Documentation

A zero dependency clone of Typer. The most convenient way to make CLI out of your programs.

Installation

Platitudes is available on pypi:

pip install platitudes

if you really want to avoid pulling code from the internet you can just vendor it into your project by copying the platitudes folder into it. As long as you are running Python>=3.10 everything should be fine.

Quick Start

from enum import Enum
from pathlib import Path
from typing import Annotated

import platitudes as pl

app = pl.Platitudes()

class Color(Enum):
    RED = 0
    GREEN = 1
    BLUE = 2

@app.command()
def build_profile(
    name: Annotated[str, pl.Argument(help="User name")],  # Adding help strings
    surname: str,
    age: int,
    photo_file: Annotated[
        Path, pl.Argument(exists=True)  # Paths can be checked for existence
    ],
    favorite_color: Color = Color.RED,  # Optional enum argument with a default
):
    print(f"The user is named {name} {surname} and his favorite color is {favorite_color}")
    print(f"Age: {age}")
    print(f"Picture stored at: {photo_file}")

    assert isinstance(photo_file, Path)
    assert isinstance(favorite_color, Color)

if __name__ == "__main__":
    app()

You can then show the help for build_profile:

❯ python example/readme_example.py build_profile --help
usage: readme_example.py build_profile [-h] [--favorite-color {0,1,2}] name surname age photo-file

positional arguments:
  name                  User name
  surname
  age
  photo-file

options:
  -h, --help            show this help message and exit
  --favorite-color {0,1,2}
                        - (default: Color.RED)

And you can run the CLI with the positional and perhaps optional arguments:

❯ python example/examples.py build_profile G Ballesteros 42 ./LICENSE
The user is named G Ballesteros and his favorite color is Color.RED
Age: 3
Picture stored at: LICENSE

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

platitudes-1.1.3.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

platitudes-1.1.3-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file platitudes-1.1.3.tar.gz.

File metadata

  • Download URL: platitudes-1.1.3.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.9 Darwin/22.6.0

File hashes

Hashes for platitudes-1.1.3.tar.gz
Algorithm Hash digest
SHA256 b2cddd8e0b0c122976984333a829f8859e70d39e8ba6f62382afc14c4de28b51
MD5 8c927331d290913f145a6e062e17edbf
BLAKE2b-256 8b7ccaa87960fc3dfa4e4b9e683f2bc605046d91f26b37a9c3c68c0bad7d18ee

See more details on using hashes here.

File details

Details for the file platitudes-1.1.3-py3-none-any.whl.

File metadata

  • Download URL: platitudes-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.9 Darwin/22.6.0

File hashes

Hashes for platitudes-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7c12a60fb2b2e18a20775672caf26778dbcd783d7dc1e1f4cf18b44ef791ec01
MD5 18789ac6ebf7bad82b5bd2aa5b9bf688
BLAKE2b-256 486eac1e2724b2139bf8813bea9d3ec46f21e954921be0a34577e97d91c1acd1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page