argumint


Nameargumint JSON
Version 1.0.5 PyPI version JSON
download
home_pageNone
SummaryA fresh new way to handle cli
upload_time2024-03-26 09:49:14
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseGPL-3.0-or-later
keywords cli command line simplified fresh
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ArguMint
 A fresh new way to handle cli
## How to use it
```python
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())
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "argumint",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "Cariel Becker <cariel.becker@gmx.de>",
    "keywords": "cli, command line, simplified, fresh",
    "author": null,
    "author_email": "Cariel Becker <cariel.becker@gmx.de>",
    "download_url": "https://files.pythonhosted.org/packages/a8/be/5647417f2880ce53cbda4e65d1f88cc3a676ba1e63ca56198c4c681f2e64/argumint-1.0.5.tar.gz",
    "platform": null,
    "description": "# ArguMint\n A fresh new way to handle cli\n## How to use it\n```python\nfrom argumint import ArgStruct, ArguMint\nfrom typing import Literal\nimport sys\n\ndef sorry(*args, **kwargs):\n    print(\"Not implemented yet, sorry!\")\n\ndef help_text():\n    print(\"Build -> dir/file or help.\")\n\ndef build_file(path: Literal[\"./main.py\", \"./file.py\"] = \"./main.py\", num: int = 0):\n    \"\"\"\n    build_file\n    :param path: The path to the file that should be built.\n    :param num:\n    :return None:\n    \"\"\"\n    print(f\"Building file {path} ..., {num}\")\n\nfrom aplustools.package import timid\n\ntimer = timid.TimidTimer()\n\narg_struct = {'apt': {'build': {'file': {}, 'dir': {'main': {}, 'all': {}}}, 'help': {}}}\n\n# Example usage\nbuilder = ArgStruct()\nbuilder.add_command(\"apt\")\nbuilder.add_nested_command(\"apt\", \"build\", \"file\")\n\nbuilder.add_nested_command(\"apt.build\", \"dir\", {'main': {}, 'all': {}})\n# builder.add_subcommand(\"apt.build\", \"dir\")\n# builder.add_nested_command(\"apt.build.dir\", \"main\")\n# builder.add_nested_command(\"apt.build.dir\", \"all\")\n\nbuilder.add_command(\"apt.help\")\n# builder.add_nested_command(\"apt\", \"help\")\n\nprint(builder.get_structure())  # Best to cache this for better times (by ~15 microseconds)\n\nparser = ArguMint(default_endpoint=sorry, arg_struct=arg_struct)\nparser.add_endpoint(\"apt.help\", help_text)\n\nparser.add_endpoint(\"apt.build.file\", build_file)\n\nsys.argv[0] = \"apt\"\n\n# Testing\n# sys.argv = [\"apt\", \"help\"]\n# sys.argv = [\"apt\", \"build\", \"file\", \"./file.py\", \"--num=19\"]\nparser.parse_cli(sys, \"native_light\")\nprint(timer.end())\n```\n",
    "bugtrack_url": null,
    "license": "GPL-3.0-or-later",
    "summary": "A fresh new way to handle cli",
    "version": "1.0.5",
    "project_urls": {
        "Documentation": "https://github.com/adalfarus/argumint/wiki",
        "Home": "https://pypi.org/project/argumint/",
        "Issue tracker": "https://github.com/adalfarus/argumint/issues",
        "Repository": "https://github.com/adalfarus/argumint"
    },
    "split_keywords": [
        "cli",
        " command line",
        " simplified",
        " fresh"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "493473422fd2636077c201c70b63ee99a2c5969fa4779e373e50c19861dd0d84",
                "md5": "beaf726f0b16d57b24cd0571336b36bf",
                "sha256": "58e7a481bdce8cc50fae17bad70db4286e2cdbd938483c1e718e78cd0f429f3b"
            },
            "downloads": -1,
            "filename": "argumint-1.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "beaf726f0b16d57b24cd0571336b36bf",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 19180,
            "upload_time": "2024-03-26T09:49:13",
            "upload_time_iso_8601": "2024-03-26T09:49:13.254587Z",
            "url": "https://files.pythonhosted.org/packages/49/34/73422fd2636077c201c70b63ee99a2c5969fa4779e373e50c19861dd0d84/argumint-1.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a8be5647417f2880ce53cbda4e65d1f88cc3a676ba1e63ca56198c4c681f2e64",
                "md5": "0cffb5c54c7fdfe75ae6d8dba47fadb5",
                "sha256": "cce7e6c0787b843b61149a23e31536f07ffda75854f8bea7ffc68052a28c79b4"
            },
            "downloads": -1,
            "filename": "argumint-1.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "0cffb5c54c7fdfe75ae6d8dba47fadb5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 19022,
            "upload_time": "2024-03-26T09:49:14",
            "upload_time_iso_8601": "2024-03-26T09:49:14.926444Z",
            "url": "https://files.pythonhosted.org/packages/a8/be/5647417f2880ce53cbda4e65d1f88cc3a676ba1e63ca56198c4c681f2e64/argumint-1.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-26 09:49:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "adalfarus",
    "github_project": "argumint",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "argumint"
}
        
Elapsed time: 0.21466s