Skip to main content

A tool to create a command-line interface for your app using python

Project description

betterargs

A tool to create a command-line interface for your app using python

Installation

  • Requirements
    • python3.10
    • pip3
pip install betterargs

Releases

Packaging and releases are handled in the packaging branch.

MAIN BRANCH IS RESERVED FOR MAINTAINING CODE ONLY!!!

Usage

  • Create a command string in YAML format in a:

    1. YAML file
    2. Python dictionary
    3. Python string
  • Convert the yaml file to command line namespace using appropriate function

1. Using a YAML file

# Create command tree in a yaml file

git:
    args:
        path:
            atype: flag
            help: Path of the repo
    subparsers:
        parsers:
            clone:
                args:
                    quiet-clone:
                        atype: flag
                        help: Operate quietly. Progress is not reported to the standard error stream.
                    no-checkout:
                        help: No checkout of HEAD is performed after the clone is complete
            init:
                args:
                    quiet-init:
                        atype: flag
                        help: Operate quietly. Progress is not reported to the standard error stream.
# Import betterargs
import betterargs


# Create command line namespace and get arguments
command_tree_PATH = 'command_tree.yaml'

args = betterargs.format_path_tree(command_tree_PATH)

2. Using Python Dictionary in YAML Format

# Import betterargs
import betterargs


# Define command tree in a dictionary in YAML format
command_tree_DICT = {
    "git": {
        "args": {
            "path": {
                "atype": "flag",
                "help": "Path of the repo",
            },
        },
        "subparsers": {
            "parsers": {
                "clone": {
                    "args": {
                        "quiet-clone": {
                            "atype": "flag",
                            "help": "Operate quietly. Progress is not reported to the standard error stream.",
                        },
                        "no-checkout": {
                            "help": "No checkout of HEAD is performed after the clone is complete"
                        },
                    },
                },
                "init": {
                    "args": {
                        "quiet-init": {
                            "atype": "flag",
                            "help": "Operate quietly. Progress is not reported to the standard error stream.",
                        },
                    },
                },
            },
        },
    },
}


# Create command line namespace and get arguments
args = betterargs.format_dict_tree(command_tree_DICT)

3. Using string in YAML Format

# Import betterargs
import betterargs


# Define command tree in a string in YAML format
command_tree_STR = """
git:
    args:
        path:
            atype: flag
            help: Path of the repo
    subparsers:
        parsers:
            clone:
                args:
                    quiet-clone:
                        atype: flag
                        help: Operate quietly. Progress is not reported to the standard error stream.
                    no-checkout:
                        help: No checkout of HEAD is performed after the clone is complete
            init:
                args:
                    quiet-init:
                        atype: flag
                        help: Operate quietly. Progress is not reported to the standard error stream.
"""


# Create command line namespace and get arguments
args = betterargs.format_str_tree(command_tree_STR)

Contributors

Contribution

You are more than welcome to contribute 😊

Process

It's simple!!!

  • Fork the github repo

  • Clone the github repo

git clone https://github.com/danielmuringe/betterargs
  • Make your modifications in the dev branch

  • Merge into main branch respecting the .gitignore of the main branch. KEEP IT CLEAN PLEASE !!!

  • Create pull request

  • Wait for confirmation

Rules

  1. Active changes must take place in the dev branch. Active changes include:

  2. Tests must be put in the testing directory of dev branch

  3. All packaging must be done in the packaging branch

Other rules will be added at my discretion

Tests

Documentation

Coming Soon 😊

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

betterargs-0.0.3.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

betterargs-0.0.3-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file betterargs-0.0.3.tar.gz.

File metadata

  • Download URL: betterargs-0.0.3.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for betterargs-0.0.3.tar.gz
Algorithm Hash digest
SHA256 7c3e900b1313dd2bffd33e5b4ff34e5db37590138a243fd7f091a93707a9304a
MD5 83f241ebac996495660c61a6cd530bae
BLAKE2b-256 41e0b1f11eafb7bc9f5f69c3b9a859034cd64bad19a33ee9f36b12a5f39bb0a6

See more details on using hashes here.

File details

Details for the file betterargs-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: betterargs-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for betterargs-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7f5c80a2f646c692fa86a33b78d2dfc4cb716a377664857ace1f27c8af19f8e8
MD5 0e3ea44fd8844494ee37ed4bba88356e
BLAKE2b-256 1e31291daf32192a2902e2afc156e9358aef7e7e3ffa307ee96965205a32fd87

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page