Skip to main content

A simple, extensible git like CLI framework.

Reason this release was yanked:

broken package

Project description

monxcli

Getting started

an arg parser decorator to simplify argument parsing

Name

monxcli

Description

"A lightweight and extensible CLI framework for building modular, Git-like command-line tools. Simplify command grouping, subcommand handling, and argument parsing with a decorator-based approach."

Usage

the following structure should be use. Scripts are group according to modules

<folder>/
        + <folder>/
            - yourscript.py
        main.py

example
monxcli
├── monxcli/
├── main.py
├── mc <-- example scripts are in this module 
│   ├── __init__.py
│   └── math_commands.py

using the decorator example:

Import the commands module and use the @commands.command decorator to define your CLI commands. The decorator automatically registers your functions with the argument parser.

For example, the code below creates two commands for your CLI under the mc group and the math_command subgroup. The functions will be registered as subcommands, and their arguments will be mapped to CLI options.

from monxcli.commands import commands  # Shared LazyCommandParser

@commands.command()
@staticmethod
def add(x: int, y: int):
    """Adds two numbers."""
    print(f"The result of {x} + {y} is {x + y}")

@commands.command()
@staticmethod
def subtract(x: int, y: int):
    """Subtracts two numbers."""
    print(f"The result of {x} - {y} is {x - y}")

To activate the CLI, your main function should just import the modules where the commands are defined. Monxcli will take of the rest.

from mc import math_commands  # just import your module/script here

from monxcli.commands import commands  # Shared LazyCommandParser


if __name__ == "__main__":
    # Execute commands only if the script is run as the main module
    commands()

running the main script example:

> python3 main.py mc math_commands add --x 3 --y 3

mc is the folder or module and math_commands is the submodule, 'add' is the function you want to call then --x and --y are the arguments passed to your functions.

result:

$ python3 main.py mc math_commands add --x 3 --y 3
The result of 3 + 3 is 33

Support

contact author https://gitlab.com/mongkoy/

Roadmap

If you have ideas for releases in the future, it is a good idea to list them in the README.

Contributing

State if you are open to contributions and what your requirements are for accepting them.

For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.

You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.

Project status

on-going

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

monxcli-1.0.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

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

monxcli-1.0.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file monxcli-1.0.0.tar.gz.

File metadata

  • Download URL: monxcli-1.0.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for monxcli-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5c7292c68691143d4a898dddadce6df46f1123a01ec89569a9d3ccfe3bd70653
MD5 25fc674f58bf5689fd3fd1432efc13e1
BLAKE2b-256 2ef6057d5ba7674f143eb623134da6f303a0fdfdb7615cd6c02795a783e1aff0

See more details on using hashes here.

File details

Details for the file monxcli-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: monxcli-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for monxcli-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ee25ec968ab64e41f6e2ed2788fec6b919406eb90fbe0b8c6d354f1b13a229b1
MD5 ced20ef3d5470f223c1cb79c727616d6
BLAKE2b-256 b24f911530eddf1d1b453f58f4a90b9ff2b7029618d053999c4fe2c530a76ef2

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