fargv


Namefargv JSON
Version 0.1.8 PyPI version JSON
download
home_pagehttps://github.com/anguelos/fargv
SummaryA very easy to use argument parser.
upload_time2023-04-17 19:37:47
maintainer
docs_urlNone
authorAnguelos Nicolaou
requires_python>=3.6
licenseMIT
keywords argv cli argument
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # fargv: The laziest command-line argument parser  

## Installation

```bash
pip3 pip install --user --upgrade git+https://github.com/anguelos/fargv
```

## Usage in 3 Simple Steps!

Fast argument parser

* Import
```python
"""
The script's docstring Becomes the general description in the help if defined
"""

from fargv import fargv 
```
* Define a dictionary with default parameters
```python
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
```python
new_params, help_str = fargv(params)
```

* In shell:
```bash
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.
```bash
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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/anguelos/fargv",
    "name": "fargv",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "argv,CLI,argument",
    "author": "Anguelos Nicolaou",
    "author_email": "anguelos.nicolaou@gmail.com",
    "download_url": "",
    "platform": "any",
    "description": "# fargv: The laziest command-line argument parser  \n\n## Installation\n\n```bash\npip3 pip install --user --upgrade git+https://github.com/anguelos/fargv\n```\n\n## Usage in 3 Simple Steps!\n\nFast argument parser\n\n* Import\n```python\n\"\"\"\nThe script's docstring Becomes the general description in the help if defined\n\"\"\"\n\nfrom fargv import fargv \n```\n* Define a dictionary with default parameters\n```python\nparams = {\n    \"anInt\": 1,\n    \"aFloat\": 0.1,\n    \"aBoolean\": False,\n    \"anotherBoolean\": True,\n    \"aString\": \"Hello\",\n    \"aStringReference\": \"{aString} World\",\n    \"anIntWithHelp\": [2,\"This would be the help\"],\n    \"aChoice\": [(\"choice1\",\"choice2\",\"choice3\",\"choice4\"),\"And this must be the help\"],\n    \"aPositionalSwitch\": [set([]), \"This is a convenient way to pass colections of things\"]\n}\n```\n\n* Parse user provided argv to override defaults\n```python\nnew_params, help_str = fargv(params)\n```\n\n* In shell:\n```bash\nmy_program -anInt 34 -aFloat=2.3 -aBoolean -anotherBoolean=False\n```\n\n## Features:\n* Type checking\n* Automatic help generation\n* Params usable as dictionary or struct\n* Can read environmental variables as well\n* macro-parameters\n* fast autocomplete generation\n* Switches with positional values \n\n### Autocomplete\n\nStatic autocomplete for any program using fargv can be enabled with a single command.\n\nThe following command enables autocomplete for fargv_demo.py in the current shell where it is run.\n```bash\nsource <(./examples/fargv_demo.py -bash_autocomplete)\n```\nfargv_demo.py should be an executable file employing the shebang (#!/usr/bin/env python3) or something equivalent.\nFor a temporary solution, the autocomplete bash code can go in a script in /etc/bash_completion.d or in .bashrc.\n\n### Switch Macros\n\nA switch might be a macro for other switches.\nThis allows for example to break many files into a single root switch and all other switches beeing file names relative to that path.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A very easy to use argument parser.",
    "version": "0.1.8",
    "split_keywords": [
        "argv",
        "cli",
        "argument"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8255e55b26aaaad30593a5b1f0d2cade94f540a09334ab0ff4ff5d93caa4654e",
                "md5": "a3724c79606db3435a4d8050e3b07646",
                "sha256": "44f4aff150646d05171ee61883ecda8a6dc7f1509025ca9b27b63dcae80ecf56"
            },
            "downloads": -1,
            "filename": "fargv-0.1.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a3724c79606db3435a4d8050e3b07646",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 11632,
            "upload_time": "2023-04-17T19:37:47",
            "upload_time_iso_8601": "2023-04-17T19:37:47.015136Z",
            "url": "https://files.pythonhosted.org/packages/82/55/e55b26aaaad30593a5b1f0d2cade94f540a09334ab0ff4ff5d93caa4654e/fargv-0.1.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-17 19:37:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "anguelos",
    "github_project": "fargv",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "fargv"
}
        
Elapsed time: 0.06304s