Skip to main content

A utility library to dynamically remove and rename arguments from argparse.ArgumentParser objects.

Project description

Argparse Utils (tddschn)

Utilities for dynamically removing or renaming argparse arguments without rewriting the original CLI definition.

Features

  • Remove an option (including from mutually exclusive groups) by dest or option string.
  • Replace an argument's option strings atomically with conflict detection.

Installation

pip install argparse-utils-tddschn

Usage

import argparse
from argparse_utils import remove_argument, replace_argument_names

parser = argparse.ArgumentParser()
parser.add_argument("-c", "--config")
parser.add_argument("--dry-run", action="store_true")

remove_argument(parser, "--dry-run")
replace_argument_names(parser, "--config", ["-C", "--configuration"])

Development

python -m venv .venv
source .venv/bin/activate
pip install -e .[dev]
pytest

License

MIT

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

argparse_utils_tddschn-0.2.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

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

argparse_utils_tddschn-0.2.0-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file argparse_utils_tddschn-0.2.0.tar.gz.

File metadata

  • Download URL: argparse_utils_tddschn-0.2.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for argparse_utils_tddschn-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f71668953702ab93d34b81ff2f70d9ee3b7cc1f510d11462d0e27ec90aa59f73
MD5 3cac584f6eb6310762bde621606853e8
BLAKE2b-256 118727e30acda52ebb1c4babeafdd983a9b845f8a70d1dd706c6f8cb4fa07025

See more details on using hashes here.

File details

Details for the file argparse_utils_tddschn-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for argparse_utils_tddschn-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ff6f0f2193c2a9714d4e1fc0ba140e80da92b164150e4e293ed77d2d058e68ce
MD5 6531b05601b95128c48548c333bb2bac
BLAKE2b-256 04529c7478171d287f4127f2473309dc7a731d035b42e38ab7fb40f573ff1755

See more details on using hashes here.

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