cmdplug
cmdplug is a lightweight Python package that makes it easy to build command-line interfaces using argparse.
Usage
Create a command class by inheriting from Command provided by cmdplug.
# example: calculator.py
from argparse import ArgumentParser, Namespace
from cmdplug import Command
class Calculator(Command):
NAME="calculator"
HELP="for example"
@classmethod
def add_arguments(cls, parser: ArgumentParser):
parser.add_argument("-x", "--x", help="x variable", type=int)
parser.add_argument("-y", "--y", help="y variable", type=int)
def run(self, args: Namespace) -> int:
x, y = args.x, args.y
print(f"x({x}) + y({y}) = {args.x + args.y}")
return 0
Then, in your main entry point, simply import the command class and call command_init().
from exmaple import Calculator
from cmdplug import __command_init__
if __name__ == "__main__":
__command_init__()
Developer’s Note
I hope you enjoy building your own CLI tools with cmdplug and have fun coding!
Release files for cmdplug 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cmdplug-1.0.0.tar.gz | 3.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cmdplug-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.2 kB
Release files / cmdplug-1.0.0.tar.gz
| Download URL | cmdplug-1.0.0.tar.gz |
|---|---|
| Size | 3.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6c0a33b8d92ae12b7858320e385433af5d5f81c1bcdc87cc7362f7f0fc2cd108
|
|
BLAKE2b-256 checksum How to use checksums |
8aac52ed34aa933012e7cf6aafff265bc9eae926f63ac36aa041785c27ca9160
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|
Release files / cmdplug-1.0.0-py3-none-any.whl
| Download URL | cmdplug-1.0.0-py3-none-any.whl |
|---|---|
| Size | 3.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e21d052f4380e47ba180def0b2cc3bf75de7f9279f4c73055c12dae2e32ae682
|
|
BLAKE2b-256 checksum How to use checksums |
4cb1ca7c2aaa52a4547947e4f359cdaa2d269a61e03588dd03465f05e7a7e778
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|