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

  • Immport
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"]
}
  • 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

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.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

fargv-0.1.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fargv-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.9

File hashes

Hashes for fargv-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5f941c3a273f7209c6bdab457082e772c9de2ca48233c0b0083ce40c920dbbe5
MD5 94874c365b7156616057919b3826d5ec
BLAKE2b-256 eb9f6de92a9ac5b4f8c85f262f6eff64218ec8577278c9a205daf440ab0ac1ae

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