Skip to main content

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

Release files for platitudes 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for platitudes 2.0.0
File Size Uploaded
platitudes-2.0.0.tar.gz 10.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for platitudes 2.0.0
File Interpreter ABI Platform
platitudes-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 21.4 kB

Release files / platitudes-2.0.0.tar.gz

Download URL platitudes-2.0.0.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ba2309502cb54f467a0dc85980199e5d2d1e4a5b65363dd3c836292aefae4e2b
BLAKE2b-256 checksum
How to use checksums
c8f15e97894ee0d86f8c584820a44e515c5cb872f36b0b9610b3fbc97d45308d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.11.9 Darwin/22.6.0

Release files / platitudes-2.0.0-py3-none-any.whl

Download URL platitudes-2.0.0-py3-none-any.whl
Size 10.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf58920c090c2d02ae8d497936d8c8302e7ef7f5c80310bc225add9ddaeba2fe
BLAKE2b-256 checksum
How to use checksums
37df93d5f6ffa4a7cd2ef2e93914d099f9696e15f4dcfa77ec81f319fd84fae8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.11.9 Darwin/22.6.0

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page