Skip to main content

Generate enhanced menu-driven CLI programs with ease!

Project description

 _                               _ _
| |                             | (_)
| |__  _   _ _ __   ___ _ __ ___| |_
| '_ \| | | | '_ \ / _ \ '__/ __| | |
| | | | |_| | |_) |  __/ | | (__| | |
|_| |_|\__, | .__/ \___|_|  \___|_|_|
        __/ | |
       |___/|_|               v 1.0.0

hypercli

hypercli is a Python package that provides an elegant solution for interacting with command line tools. It offers a menu-based command line interface (CLI) that allows users to navigate through different options and execute functions based on their choices.

Features

  • Generate menu-driven CLI programs with ease using decorators
  • Customize the menus, options, and visual styles according to your requirements
  • Supports nested menus and navigation between menus

Installation

You can install hypercli using pip. Open your terminal and run the following command:

pip install hypercli

Usage

To use hypercli, import the hypercli module from the hypercli package and create an instance of the hypercli class. You can then define your menus, options, and functions to be executed. Finally, call the run() method to start the CLI interface.

Here's an example of how to use hypercli:

# import hypercli
from hypercli import hypercli

# create an instance of hypercli
cli = hypercli()

# configure the instance
cli.config["banner_text"] = "HYPERCLI"
cli.config["intro_title"] = "Intro"
cli.config["intro_content"] = "Generate enhanced menu-driven CLI programs with ease!"
cli.config["show_menu_table_header"] = True

# add navigation options to the menu
cli.link("Main Menu", "Mathematics Menu")
cli.link("Main Menu", "String Menu")


@cli.entry(menu="Main Menu", option="Greeter")
def greet():
    name = input("Enter your name: ")
    print(f"Hello, {name}!")


@cli.entry(menu="Mathematics Menu", option="Add two numbers")
def add(num1=1, num2=1):
    a = int(input(f"Enter first number (default {num1}): ") or num1)
    b = int(input(f"Enter second number (default {num2}): ") or num2)
    print(f"{a} + {b} = {a + b}")


@cli.entry(menu="Mathematics Menu", option="Subtract two numbers")
def sub(num1=1, num2=1):
    a = int(input(f"Enter first number (default {num1}): ") or num1)
    b = int(input(f"Enter second number (default {num2}): ") or num2)
    print(f"{a} - {b} = {a - b}")


@cli.entry(menu="String Menu", option="Reverse a string")
def reverse():
    string = input("Enter a string: ")
    print(string[::-1])


@cli.entry(menu="String Menu", option="Show length of a string")
def str_length():
    string = input("Enter a string: ")
    print(f"Length of string is {len(string)}")


# run the cli
cli.run()

The above script demonstrates the usage of hypercli. It creates a CLI with two menus: "Main Menu" and "Sub Menu". Each menu has its own options and functions to be executed. You can customize the menus, options, and visual styles according to your requirements. To check out more complex example, refer to Example_revamped.py.

License

This project is licensed under the MIT License. See the MIT file for more information.

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

hypercli-1.0.0.tar.gz (6.0 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: hypercli-1.0.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for hypercli-1.0.0.tar.gz
Algorithm Hash digest
SHA256 fc72dc72210fd0b62123c1b0ba59b3d78d4d7c30787db593fc56f93b72f0dd8d
MD5 407763b26dc06325f1f81af01166018f
BLAKE2b-256 fcd69112618feded0ca47b48c9b71a21d1af4101236ef4388139c7bb9dd7d63a

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