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.1.0.tar.gz (21.9 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.1.0-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for argumentor-2.1.0.tar.gz
Algorithm Hash digest
SHA256 65707ac55f0bf0357865cdf45de83472802a046788902388d2eea995c4b291bb
MD5 d8e0d8f4b089548a1ef129cc10918abc
BLAKE2b-256 a738255ecf0a105bbf69b1dabdf462423b400a3f323fcc124c07bec35f02304c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: argumentor-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.9 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0e4811aeef8517e51006917a5c15346b070760f9ce696de72fd502b1d88b7a8e
MD5 448f55985c73b0af220833741bbebc35
BLAKE2b-256 de8d7313fd4cd26ee0c628150ddeda758863c15f786615dece830c5d3e309517

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