Skip to main content

Modified version of argparse which remembers the order of CLI arguments

Project description

ordered_argparse

Version of Python's standard library's argparse which also remembers the order of command line arguments.

Installation

Install with pip install ordered_argparse.

Usage

Create an instance of ArgumentParser as usual. Use namespace=ordered_argparse.OrderedNamespace(). Access arguments in declaration order by calling parser's .ordered() method.

import ordered_argparse

parser = ordered_argparse.ArgumentParser()
parser.add_argument("--foo", action="store_true", help="foo")
parser.add_argument("--bar", action="store_true", help="bar")

# Use OrderedNamespace when parsing CLI arguments
args = parser.parse_args(["--foo", "--bar"], namespace=ordered_argparse.OrderedNamespace())

# Access ordered arguments by calling .ordered()
for arg in args.ordered():
    print(f"{arg}")

Compatibility with argcomplete

ordered_argparse only works with argcomplete as long as you don't use subparsers. If you use subparsers, you need ordered_argcomplete.

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

ordered_argparse-1.0.10.tar.gz (26.0 kB view details)

Uploaded Source

Built Distribution

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

ordered_argparse-1.0.10-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

File details

Details for the file ordered_argparse-1.0.10.tar.gz.

File metadata

  • Download URL: ordered_argparse-1.0.10.tar.gz
  • Upload date:
  • Size: 26.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for ordered_argparse-1.0.10.tar.gz
Algorithm Hash digest
SHA256 a930c290552e221b53cdfe2c832fce2e83031e403ceb1084b4a00b3e00155a73
MD5 32f19f5fea1a8fb9c57b2d7e0a773795
BLAKE2b-256 1e2a0b8b6e33385a4a2da6621cf03d6113818b97dde0a25c38f83db5ac06f577

See more details on using hashes here.

File details

Details for the file ordered_argparse-1.0.10-py3-none-any.whl.

File metadata

  • Download URL: ordered_argparse-1.0.10-py3-none-any.whl
  • Upload date:
  • Size: 25.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for ordered_argparse-1.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 0c960dc733b1ee8a5fe1d7134596fbb98cf7a99b4648b78aa4f2179153d4c58b
MD5 744cb09badb1e7e49cf7125a781adc1e
BLAKE2b-256 054e4963f928549cc8aab500196884296633ae9a6b7d9f7cd7a1cf55b6c83a36

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