Metadata-Version: 2.4
Name: cmdchopper
Version: 0.2.0
Summary: Yet another command parser.
Author-email: 0x4D2 <1706119930@qq.com>
License: MIT
Project-URL: Homepage, https://github.com/0x4D25F2/cmdchopper
Project-URL: Issues, https://github.com/0x4D25F2/cmdchopper/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# cmdchopper

Yet another command parser.

[![PyPI version](https://badge.fury.io/py/cmdchopper.svg)](https://badge.fury.io/py/cmdchopper)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## Usage
Working in progress...

## Example
```python
from cmdchopper import CommandParser, Arg, Stat
from cmdchopper.checkers import minn
import random


def rand(command: str):
    parser = CommandParser(
        [
            Arg["n", int, minn(1)].blocked(),
            Arg["l", int]["r", int],
            Arg["exp", str]
        ],
        ["!dice", "!roll"]
    )
    stat, output, idx = parser.parse(command)
    if stat == Stat.SUCCESS:
        args = output
        if idx == 0:
            return random.randint(1, args.n)
        elif idx == 1:
            return random.randint(args["l"], args["r"])
        elif idx == 2:
            value = 0
            # Something else...
            return value
    else:
        return f"Failed {output}"


print(rand("!dice 1 6"))
print(rand("!roll"))  # Failed (missing arguments)
```

## Installation

```bash
pip install cmdchopper
