Skip to main content

CLI value guards for argparse and Typer.

Project description

cliguards

CLI value guards for argparse and Typer.

argparse

Use guards as native argparse type= converters:

import argparse

from cliguards import PathGuard

parser = argparse.ArgumentParser()
parser.add_argument("--input", type=PathGuard.file("tsv", "tsv.gz"))

args = parser.parse_args()

Typer

Install the optional Typer extra:

pip install "cliguards[typer]"

Use fluent adapters with Annotated:

from pathlib import Path
from typing import Annotated

import typer

from cliguards import PathGuard

app = typer.Typer()


@app.command()
def run(
    input: Annotated[
        Path,
        PathGuard.file("tsv", "tsv.gz").as_typer_option("--input"),
    ],
) -> None:
    typer.echo(input)

Public API

from cliguards import HexColorGuard, NumericRangeGuard, PathGuard

V1 guards are single-value guards. They do not expose public specs, public guard error classes, automatic help generation, or multi-value helpers.

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

cliguards-0.1.0.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

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

cliguards-0.1.0-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file cliguards-0.1.0.tar.gz.

File metadata

  • Download URL: cliguards-0.1.0.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cliguards-0.1.0.tar.gz
Algorithm Hash digest
SHA256 69b4e207f47149905e1a83ee6cc1ffd4ff051be24a853a2ffecd9fb0c203991d
MD5 5dcb4b2ffc5847094d4ffd9f74992f40
BLAKE2b-256 2380f0834ca31c685c18ac89f2d6a97662305b231eedf104689b59689735cbd9

See more details on using hashes here.

Provenance

The following attestation bundles were made for cliguards-0.1.0.tar.gz:

Publisher: publish.yml on FuqingZh/cliguards

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

File details

Details for the file cliguards-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cliguards-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cliguards-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ea1341b5e839405f49aaebfd452f2c9b780350fc739fad0414e4c193febfcc96
MD5 4a8890de5c4bb1512a83d2ba0d1ebdb5
BLAKE2b-256 31bbcd8b5028315b0431f58d49fea05d0a2bba4b3a954724dd34a523a91286a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for cliguards-0.1.0-py3-none-any.whl:

Publisher: publish.yml on FuqingZh/cliguards

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