Welcome to argparse_action’s documentation!

Concept

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

Example

"CLI option flag from boolean default value"
import sys
import argparse
import argparse_action

def main():
    namespace = parser.parse_args()
    namespace.action(namespace)

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

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

if __name__ == "__main__":
    main()

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

$ python3 main.py echo hello
hello
$ python3 main.py echo hello --upper
HELLO

Installation

pip install argparse_action

Articles

API reference

Indices and tables