A very easy to use argument parser.
Project description
fargv: The laziest command-line argument parser
Installation
pip3 pip install --user --upgrade git+https://github.com/anguelos/fargv
Usage in 3 Simple Steps!
Fast argument parser
- Import
from fargv import fargv
- Define a dictionary with default parameters
params = {
"anInt": 1,
"aFloat": 0.1,
"aBoolean": False,
"anotherBoolean": True,
"aString": "Hello",
"aStringReference": "{aString} World",
"anIntWithHelp": [2,"This would be the help"],
"aChoice": [("choice1","choice2","choice3","choice4"),"And this must be the help"],
"aPositionalSwitch": [set([]), "This is a convenient way to pass colections of things"]
}
- Parse user provided argv to override defaults
new_params, help_str = fargv(params)
- In shell:
my_program -anInt 34 -aFloat=2.3 -aBoolean -anotherBoolean=False
Features:
- Type checking
- Automatic help generation
- Params usable as dictionary or struct
- Can read environmental variables as well
- macro-parameters
- fast autocomplete generation
- Switches with positional values
Autocomplete
Static autocomplete for any program using fargv can be enabled with a single command.
The following command enables autocomplete for fargv_demo.py in the current shell where it is run.
source <(./examples/fargv_demo.py -bash_autocomplete)
fargv_demo.py should be an executable file employing the shebang (#!/usr/bin/env python3) or something equivalent. For a temporary solution, the autocomplete bash code can go in a script in /etc/bash_completion.d or in .bashrc.
Switch Macros
A switch might be a macro for other switches. This allows for example to break many files into a single root switch and all other switches beeing file names relative to that path.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file fargv-0.1.6.tar.gz
.
File metadata
- Download URL: fargv-0.1.6.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.27.1 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.62.3 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2423066e78a7a9ea19b019bc190cfe7145b172c50cc541a8302a6767a4b441ed |
|
MD5 | c99c57b46bd3b6095a40c63fe3614ec8 |
|
BLAKE2b-256 | 1bb71c2506351db94beccfcad7367c43915d75c2aea854ac16e518c3733a1ffb |
File details
Details for the file fargv-0.1.6-py3-none-any.whl
.
File metadata
- Download URL: fargv-0.1.6-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.27.1 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.62.3 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1109a45f4c8f28c35834b8510853f8b56198b583049cc672baab8fd96a9a015 |
|
MD5 | ab82ee6249f8c3f4ea9c9567c6897e8d |
|
BLAKE2b-256 | 3fa4296e50e89877e2eb8c3dbe7adce41786173464a29b7c5c52ca271d68c1f5 |