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.

The latest release 2.0.0 brings with it a totally new and more refined interface for managing the cli. These enhancements are from the new 'autocli' package.

This is done so that an MVP of autocli exists, that can always be used in cases where using autocli may not be preferable. For example, in a minimal project the argumint.py file can easily be included while using the entire autocli directory could be more cumbersome.

Another reason is so that projects using argumint can slowly transition to autocli, while we wait for the name to be possibly available.

How to use it

from argumint import Interface, ArgumentParsingError
from typing import Literal


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


def print_program_help() -> None:
    print("This is the CLI for aps, and it does ... and ... .")


from chronix import FlexTimer

timer = FlexTimer()

# Initialization
parser = Interface("aps", path_seperator="::")

# Add endpoints / paths
parser.path("build::file", build_file)
parser.path("build::dir::main")
parser.path("build::dir::all")
parser.path("help", print_program_help)

# Testing
try:
    print("---- 1 ----")
    parser.parse_cli(["main.py", "help"])  # Displays program help
    print(timer.lap().to_readable())
    print("---- 2 ----")
    parser.parse_cli(["main.py", "build", "file", "./file.py", "--num", "19"])
    print(timer.lap().to_readable())
    print("---- 3 ----")
    parser.parse_cli()  # Displays cli help
    print(timer.lap().to_readable())
    print("---- 4 ----")  # Warning about native_light mode and error
    parser.parse_cli(["main.py", "build", "file", "./file.py", "--num", "=", "19"], "native_light")
    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-2.0.0.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

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

argumint-2.0.0-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for argumint-2.0.0.tar.gz
Algorithm Hash digest
SHA256 6c05b9ff9459bb247cc11b8d1ba263c2618bc5cef796fdddf1ab2183334c84bc
MD5 1f9722ce61ff0c140281567f19a7d9be
BLAKE2b-256 1c57dc8a654bb9447fee1cbc74558023cf5ff6096ba53c882b6dad26b0579fdf

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for argumint-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3dd3edb52f65e65b88344b0629c14c42a2d2288225000c92607e1a855d7a9631
MD5 76138fabedb491fa58a44ba36f2ee059
BLAKE2b-256 72f6eab08f5cdb0418d252d1f99da50a4c5091782aa63d7234c0625405318c08

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