Skip to main content

A fresh new way to handle cli

Project description

ArguMint

A fresh new way to handle cli.

This package is just maintained (EOL) as I have rewritten large parts of the package (2k new LOC) and plan to release them under the new name autocli. This could take a 1-2 months though as the old owner of the name seems unresponsive.

I have also updated it with the latest code from aplustools.package.autocli and applied a few patches and quality of life enhancements.

How to use it

from argumint import Argumint, ArgumentParsingError
from typing import Literal


def sorry(*args, **kwargs):
    print("This path does not have an endpoint, please use aps help to get help.")

def help_text():
    print("Build -> dir/file or help.")

def build_file(path: Literal["./main.py", "./file.py"] = "./main.py", num: int = 0):
    """
    build_file
    :param path: The path to the file that should be built.
    :param num:
    :return None:
    """
    print(f"Building file {path} ..., {num}")

from chronix import FlexTimer

timer = FlexTimer()

# Initialization
parser = Argumint(default_endpoint=sorry, arg_struct={
    'aps': {
        'build': {
            'file': {},
            'dir': {
                'main': {},
                'all': {}
            }
        },
        'help': {}
    }
})

# Add endpoints
parser.add_endpoint("aps.help", help_text)
parser.add_endpoint("aps.build.file", build_file)

# Testing
try:
    print("---- 1 ----")
    parser.parse_cli(["main.py", "help"], "native_light")
    print(timer.lap().to_readable())
    print("---- 2 ----")
    parser.parse_cli(["main.py", "build", "file", "./file.py", "--num=19"], "native_light")
    print(timer.lap().to_readable())
    print("---- 3 ----")
    parser.parse_cli(mode="native_light")
    print(timer.lap().to_readable())
    print("---- 4 ----")
    parser.parse_cli(["main.py", "build", "file", "./file.py", "--num", "=", "19"], "native_light")  # Error
    print(timer.lap().to_readable())
except ArgumentParsingError as e:
    print(f"There was an error while parsing '{e}'.")
timer.end()

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

argumint-1.1.0.tar.gz (19.9 kB view details)

Uploaded Source

Built Distribution

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

argumint-1.1.0-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file argumint-1.1.0.tar.gz.

File metadata

  • Download URL: argumint-1.1.0.tar.gz
  • Upload date:
  • Size: 19.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for argumint-1.1.0.tar.gz
Algorithm Hash digest
SHA256 d8088450f5a0b7f7bf50468e82e1120c3b1c1d52ceb0e16cb672383fa5d8a123
MD5 bc83ef4951cff8b265f3c043677b7dcf
BLAKE2b-256 e0b7ca7cf75c06d837d2c3cda7b2ec40e9caa8edf5acc23a82fc72c0146be89e

See more details on using hashes here.

File details

Details for the file argumint-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: argumint-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for argumint-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ff0f3fb3dd451d91815b28064b11831339066b979946423cf5ccf8300f0fd7b1
MD5 8958fae1396cbacf9ffa58c9eed7c5d1
BLAKE2b-256 c8f7173ece685f0c3d6587b4dcc027123f3db4d6b5dd253add410a174f4e5624

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