Skip to content

Getting started

Introduction

argumentor makes it possible to define commands and options. It can also automatically generate help pages, based on several parameters.

Usage

Below is a minimalist code snippet that aims to demonstrate some basic uses of argumentor:

demo.py
import sys
from argumentor import Argumentor
from argumentor.exc import ParsingError

argm = Argumentor("program-name")

argm.register_command(
    "cmd1",
    description="command 1",
)
argm.register_command(
    "cmd2",
    description="command 2",
)

argm.register_option(
    "--opt",
    "-o",
    description="global option 1",
)

try:
    cmd, opts = argm.parse()
except ParsingError as err:
    print(err)
    sys.exit(1)