Skip to main content

A fresh new way to handle cli

Project description

ArguMint

A fresh new way to handle cli

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.5.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

argumint-1.0.5-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: argumint-1.0.5.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.19

File hashes

Hashes for argumint-1.0.5.tar.gz
Algorithm Hash digest
SHA256 cce7e6c0787b843b61149a23e31536f07ffda75854f8bea7ffc68052a28c79b4
MD5 0cffb5c54c7fdfe75ae6d8dba47fadb5
BLAKE2b-256 a8be5647417f2880ce53cbda4e65d1f88cc3a676ba1e63ca56198c4c681f2e64

See more details on using hashes here.

File details

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

File metadata

  • Download URL: argumint-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 19.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.19

File hashes

Hashes for argumint-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 58e7a481bdce8cc50fae17bad70db4286e2cdbd938483c1e718e78cd0f429f3b
MD5 beaf726f0b16d57b24cd0571336b36bf
BLAKE2b-256 493473422fd2636077c201c70b63ee99a2c5969fa4779e373e50c19861dd0d84

See more details on using hashes here.

Supported by

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