Skip to main content

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

License

This project is licensed under the MIT License.

Credits

Thank you for using getoptify!

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

getoptify-1.0.0.tar.gz (3.2 kB view hashes)

Uploaded Source

Built Distribution

getoptify-1.0.0-py3-none-any.whl (4.0 kB view hashes)

Uploaded Python 3

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