Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fargv-0.1.3.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

fargv-0.1.3-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file fargv-0.1.3.tar.gz.

File metadata

  • Download URL: fargv-0.1.3.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.6.9

File hashes

Hashes for fargv-0.1.3.tar.gz
Algorithm Hash digest
SHA256 d86b2faa5b4d8b01e9e265bdfc9fa72e4200c36c7c05ee1ee7f301e4fae93ab6
MD5 efb82ea9759259e6f00adf325eda1944
BLAKE2b-256 991255830d84753187b951e13788beb6c39750ff21d0a0a38bf1fab576f7a9d7

See more details on using hashes here.

File details

Details for the file fargv-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: fargv-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.6.9

File hashes

Hashes for fargv-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6bca2ac8300cb43c2098727dc97db2fea288b76f5ae4338a53bb4dd4ad262e40
MD5 2e93ed7b376f0ebf4c1d4bb9b2299ebe
BLAKE2b-256 2910bf446fabea3c2ef7d9fe43c0f5d96665deaeff2625f9715ae115a32f98c9

See more details on using hashes here.

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