Skip to main content

lightweight & copylefted library to work with command-line arguments

Project description

argumentor

argumentor is a simple and lightweight library to build complex command-line tools.

Features

  • Differenciate commands from options
  • Define aliases for commands and options
  • Automatically generate help pages
  • Set default values
  • No external dependencies

Installation

Using pip

The argumentor library can be installed from the Python Package Index (PyPI):

$ pip install argumentor

Installing from source

Using pip, it is also possible to install a package directly from source.

First clone the source code repository hosted on Codeberg:

$ git clone https://codeberg.org/camelia/python-argumentor argumentor

Then, enter the local repository and install argumentor (you may want to use a virtual environment):

$ cd argumentor
$ pip install .

Usage

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

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)

More information about usage can be found in the documentation.

License

argumentor is free software! You are free to use, copy, modify, share and redistribute it under the terms of the GNU Lesser General Public License, version 3 or later.

LGPLv3 badge

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

argumentor-2.3.0.tar.gz (22.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

argumentor-2.3.0-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

Details for the file argumentor-2.3.0.tar.gz.

File metadata

  • Download URL: argumentor-2.3.0.tar.gz
  • Upload date:
  • Size: 22.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.12

File hashes

Hashes for argumentor-2.3.0.tar.gz
Algorithm Hash digest
SHA256 1d511acecb5ca989e4621d0497632f975b627cb1a67aaa160ca7dec3508987e8
MD5 3600b06e55bfa5a00bd3c70eea0bce74
BLAKE2b-256 487a150b26e02854d3b18fd48c2cbf398f63f0fbe0edfeaef09f28828b2950c7

See more details on using hashes here.

File details

Details for the file argumentor-2.3.0-py3-none-any.whl.

File metadata

  • Download URL: argumentor-2.3.0-py3-none-any.whl
  • Upload date:
  • Size: 18.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.12

File hashes

Hashes for argumentor-2.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d59410c23260dfdcc64235629bd0dd6a15850538d3a4a04c962c24bf98a667e2
MD5 b17dcc152d14078d5d3e0049366bdc1d
BLAKE2b-256 aeda5cbeff2248dace05c89f195c482e337afc9b87363a7d7927c403b28a37a1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page