Skip to main content

untility module for argparse to create cli

Project description

argparse_action

argparse_action aims to be a minimalistic extension of argparse and creates cli options from the function signature given by inspect.signature.

import argparse
import argparse_action

parser = argparse.ArgumentParser()
action = argparse_action.Action(parser)

@action.add("e")
def echo(word, upper=False):
    print(word.upper() if upper else word)

namespace = pasrer.parse_args()
namespace.action(namespace)

Asumes that the code above is saved as my_script.py:

$ python3 my_script.py echo hello
hello

$ python3 my_script.py e hello
hello

$ python3 my_script.py echo --upper hello
HELLO

Installation

pip install argparse_action

Testing

make test

Documentation

Documentation can be build with the doc make target:

make doc

Online version can be read at readthedocs.org.

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

argparse_action-0.1.1.tar.gz (7.2 kB view hashes)

Uploaded Source

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