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.1.0.tar.gz (3.7 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.1.0-py3-none-any.whl (2.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: argparse_utils_tddschn-0.1.0.tar.gz
  • Upload date:
  • Size: 3.7 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.1.0.tar.gz
Algorithm Hash digest
SHA256 d4433d983dfd999a36a921295baafb44d71431171e1ceb8e6c21b84eb2e9c6bd
MD5 bbe923743a51c99af4eafff331464a90
BLAKE2b-256 6feed406df7c0fab9bd7ec118af4caeacee778b12089fd85de5edd161a0f5396

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for argparse_utils_tddschn-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e82613622df12ebaf4e4893686b3e9b8bda49e7dd13b93c0d1571e74f8806020
MD5 76daa1e6b0af0de9e0e2f07a6c59529d
BLAKE2b-256 e17fa9f8c10bb6518c98a52d5554045374ea9bdffbf1d3ae71831eff2661f905

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