Skip to main content

An argpase that can take values from the environment.

Project description

argparse-env - argparse with environment

Use this package when you want to be able to set arguments wither at the command line or through environment variables.

from argparse_env import EnvArgumentParser

parser = EnvArgumentParser(env_prefix="MYAPP")
parser.add_argument
>>> from argparse_env import EnvArgumentParser
>>> parser = EnvArgumentParser(env_prefix='MYAPP')
>>> parser.add_argument("--hello", type=str, default="Alex" help="Say hello to.")
>>> parser.parse_args(["--hello", "Jane"])
Namespace(hello='Jane')
>>> parser.parse_args([])
Namespace(hello=Alex)
>>> import os
>>> os.environ["MYAPP_HELLO"] = "Jim"
>>> parser.parse_args([])
Namespace(hello='Jim')
>>> parser.parse_args(["--hello", "Jane"])
Namespace(hello='Jane')

argparse Feature Support

There are some extras added to the class to support argparse features from environment variables.

nargs

Provide arguments with nargs != 1 using a comma-separated list in an environment variable.

MYAPP_NARGS_MANY=arg1,arg2,arg3

store true/false

Use true, 1, or on for True or false, 0, or off for False.

MYAPP_STORE_FALSE=false
MYAPP_STORE_FALSE=off
MYAPP_STORE_TRUE=true
MYAPP_STORE_TRUE=1

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_env-0.1.1.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

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

argparse_env-0.1.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file argparse_env-0.1.1.tar.gz.

File metadata

  • Download URL: argparse_env-0.1.1.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.2

File hashes

Hashes for argparse_env-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4b913d4dc66b21d88684ffcd07b31bcf5a3def4e97dd64ccefe96a76ba74d66c
MD5 a287f2b5bc5b723987076a0b8e4a08b3
BLAKE2b-256 5c9390aca275df13592f6d0b5568b432916fc4b9e2e0eb9a640c9646be1473d5

See more details on using hashes here.

File details

Details for the file argparse_env-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for argparse_env-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e2a38e6859987f42de3550efb56dcad46b3d71a8158ebe0e90a63366a6c356b0
MD5 87ae00edeb19d94400d38d86dbddefa9
BLAKE2b-256 1ba1bd9f342851280e2db9006cb1c585fcca825ba88bdd18773e7e88c06c3605

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