getoptify
Project description
Overview
getoptify allows getopt parsing followed by deparsing, e.g. for allowing abbreviations with click or to enforce parser simplicity.
Installation
To install getoptify, you can use pip. Open your terminal and run:
pip install getoptify
Functions
def command(*_args, **_kwargs):
return functools.partial(decorator, *_args, **_kwargs)
def decorator(old, /, *_args, **_kwargs):
@functools.wraps(old)
def new(args=None):
args = process(args, *_args, **_kwargs)
return old(args)
return new
def process(args=None, shortopts="", longopts=[], allow_argv=True, gnu=True):
...
# this function is the heart of getoptify
# args are parsed using getopt and then converted back into a list of args
# allow_argv allows to default to sys.argv[1:] if args is None
# if gnu then getopt.gnu_getopt is used else getopt.getopt
Recommended Usage
@getoptify.command(shortopts="h", longopts=["foo", "bar="])
def example(args=None):
...
# here internal parsing
License
This project is licensed under the MIT License.
Links
Credits
Author: Johannes
Thank you for using getoptify!
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
getoptify-1.0.1.tar.gz
(3.1 kB
view hashes)
Built Distribution
Close
Hashes for getoptify-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1bf89a50c4c57c8be608df9f786c588f55e627a734b4c1f3aec166fb0a1c97f |
|
MD5 | 5726db1bbbdd2a0f7712e2188daeb4fa |
|
BLAKE2b-256 | c0ce933bf4fcccd028bd5dab92d74f89d823ab957f906d0deb893c7f1e330933 |