Yet another command parser.
Project description
cmdchopper
Yet another command parser.
Usage
Working in progress...
Example
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
pip install cmdchopper
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cmdchopper-0.2.0.tar.gz
(5.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cmdchopper-0.2.0.tar.gz.
File metadata
- Download URL: cmdchopper-0.2.0.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
274801d08874070801eb16592129eee212c5e79cc22929e2bccd9a20a2fc5bb1
|
|
| MD5 |
998b96e067e45cbf34d5cfce46bb874a
|
|
| BLAKE2b-256 |
fc2954671332f8e0a70644b77acb4ab74a327d76f9f73c9f362ea5f03cd942c4
|
File details
Details for the file cmdchopper-0.2.0-py3-none-any.whl.
File metadata
- Download URL: cmdchopper-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
445a2be0b7f719b7556ed502bb699099af2409998d3ea6bc9213a496258e5eff
|
|
| MD5 |
6ac86c915f021f0ef4f2d131f3f78141
|
|
| BLAKE2b-256 |
dbe38255ffe22a87cbcc1832890c7b06f7cea38583eb61287af812696469ecba
|