Skip to main content

Turn all the markdown files in your repos into one big, divio structrured documentation

Project description

AnyArgs

Get script arguments from the CLI, .conf files, environment variables and/or .env files, with only one syntax!

CLI .conf .env env vars Functionality
Add groups & arguments everywhere at once
Load arguments, no matter where they're set
Save/export args
Set list type/duplicate args

✅: Implemented ❕: Implemented in a quirky little way ❔: Planned ❌: Not implemented

How-To

(Project) Install from pip

python3 -m pip install AnyArgs 

(Code) Basic usage

In just a few lines of code, you can allow your users to set args in whatever way they prefer

# index.py
args = AnyArgs()
args.add_group("Config").add_argument("Username", help="Username for logging in")
args.load_args()
print("Provided username: " + args.get_argument("Username"))
That's it! With just these lines of code, you've allowed the following
  • A help interface through python3 index.py -h or python3 index.py --help
  • A CLI interface through python3 index.py --username Denperidge and python3 index.py -u Denperidge
  • Allow configuring through a .env in the current working directory with USERNAME=Denperidge
  • Allow configuring through environment variables with export USERNAME=Denperidge
  • Allow configuring through a *.conf in the current working directory with
    [Config]
    Username=Denperidge
    

(Code) Booleans

# index.py
args = AnyArgs()
args.add_group("Config").add_argument("Load on launch", typestring=ARGTYPE_BOOLEAN, help="Whether to load files on launch", default=False)
args.load_args()

And now, a simple python3 index.py --load-on-launch is enough to enable load-on-launch!

(Code) Explicitly defining flags

While AnyArgs will auto-generate some flags, you can always define your own instead to override this behaviour!

# index.py
args = AnyArgs()
args.add_group("Config").add_argument("Username", cli_flags=["--username", "--login", "--email"])
args.load_args()

(Project) Clone & run tests

git clone https://github.com/Denperidge-Redpencil/AnyArgs.git
cd AnyArgs
python3 -m pip install -r requirements.txt
python3 -m src.tests

(Project) Clone & run scripts locally

git clone https://github.com/Denperidge-Redpencil/AnyArgs.git
cd AnyArgs
python3 -m pip install -r requirements.txt
python3 src.AnyArgs

(Project) Clone, build & install package locally

git clone https://github.com/Denperidge-Redpencil/AnyArgs.git
cd AnyArgs
python3 -m pip install --upgrade build setuptools
python3 -m build && python3 -m pip install --force-reinstall ./dist/*.whl

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

AnyArgs-0.1.0.tar.gz (6.5 kB view hashes)

Uploaded Source

Built Distribution

AnyArgs-0.1.0-py3-none-any.whl (7.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page