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 for common errors for now.

How to use it

from argumint import ArgStruct, ArguMint
from typing import Literal
import sys

def sorry(*args, **kwargs):
    print("Not implemented yet, sorry!")

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 aplustools.package import timid

timer = timid.TimidTimer()

arg_struct = {'apt': {'build': {'file': {}, 'dir': {'main': {}, 'all': {}}}, 'help': {}}}

# Example usage
builder = ArgStruct()
builder.add_command("apt")
builder.add_nested_command("apt", "build", "file")

builder.add_nested_command("apt.build", "dir", {'main': {}, 'all': {}})
# builder.add_subcommand("apt.build", "dir")
# builder.add_nested_command("apt.build.dir", "main")
# builder.add_nested_command("apt.build.dir", "all")

builder.add_command("apt.help")
# builder.add_nested_command("apt", "help")

print(builder.get_structure())  # Best to cache this for better times (by ~15 microseconds)

parser = ArguMint(default_endpoint=sorry, arg_struct=arg_struct)
parser.add_endpoint("apt.help", help_text)

parser.add_endpoint("apt.build.file", build_file)

sys.argv[0] = "apt"

# Testing
# sys.argv = ["apt", "help"]
# sys.argv = ["apt", "build", "file", "./file.py", "--num=19"]
parser.parse_cli(sys, "native_light")
print(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.0.6.tar.gz (19.7 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.0.6-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for argumint-1.0.6.tar.gz
Algorithm Hash digest
SHA256 fc9d2a75e27e6a49e432fb46880a5456a81af6532003a4e92c607a9dd77e86ac
MD5 e07dac3bd7bcc12945129e6965a55abd
BLAKE2b-256 b46af66c2b6dd36c2cc9d46ac07a81488e00a3ec9cad153522459eaa2fa1c692

See more details on using hashes here.

File details

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

File metadata

  • Download URL: argumint-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 19.0 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.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 d4c6ba2ef391c6bbe6ada444270a38ff85dbbd2cfaf64ff21ab3d8715da76367
MD5 875a36ecbee4e1f57606c1a086106752
BLAKE2b-256 8224bcca8797e700d23bf427fd856b3590c2012dd6e373acc1dc2e8f7758e638

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