Terminalcmd - a Python library which can help you to make your own terminal program with high-intellegence instruments

Overview

terminalcmd

Terminalcmd is a Python library which can help you to make your own terminal program with high-intellegence instruments, that will make your code "clear" and readable.

Note: Library is in beta-test now, so it will update very often.

Installition

Using Pypi:
$ pip install terminalcmd

Examples of base instruments:

Base output:
import terminalcmd  # Remeber it!

terminalcmd.log("Base phrase:", "Hello world!")
Base input:
someVar = int(terminalcmd.prompt("Input some INT number here: "))
System arguments:
# Of course, you can use indexes to cut them.
terminalcmd.log(terminalcmd.args())
Object stream:
# Working like printing (not FULL) iterator:
my_list = [1, 2, 3]
terminalcmd.log(f"Maybe we need to see subobjects of {my_list}?")
terminalcmd.stream(my_list)
Iterator:
# iter(callable) example:
terminalcmd.citer([1, 2, 3])

# iter(callable, sentinel) example:
terminalcmd.log("Now let's see how it work with `terminalcmd.prompt()` and 'stop' as sentinel")
terminalcmd.citer(terminalcmd.prompt, "stop")
Clearing console:
if terminalcmd.prompt("Do you want to clear terminalcmd? (y/n): ").lower() == "y":
    terminalcmd.clear()

How to change console color watch in directory terminalcmd/examples/1-withoutBuilder/7-colorText or run next code:

import terminalcmd

terminalcmd.color_examples()

Examples of BuilderCore:

Easy-to-build greeter:
None: # Create functiuon. As command name in console will be used function name. name = prompt("What's your name: ") # Base input. log(f"Hello {name}!") # Base log into console. if __name__ == "__main__": builder.build() # Start console.">
from terminalcmd import (
    builder,  # To build your app you need this module.
    log,
    prompt
)


@builder.command(  # Decorator create commands.
    short_descrtiption="Greet you!",  # Set description, that will be shown in help-message.
    usage="greet (No arguments)"  # Let user know how to use this command.
                                  # Of course, all this params can be unfilled.
)
def greet() -> None:  # Create functiuon. As command name in console will be used function name.
    name = prompt("What's your name: ")  # Base input.
    log(f"Hello {name}!")  # Base log into console.


if __name__ == "__main__":
    builder.build()  # Start console.
Builtins:
from terminalcmd import builder, log


@builder.command()  # Create some random command.
def hello() -> None:
    """Say "Hello!" to user."""
    log("hello!")


if __name__ == "__main__":
    builder.build()

If you'll run this file and type 'help', you'll see that you have 3 commands: 'help', 'exit' and 'hello'. But why? You added only one! It's because of builtins commands:

Command help show all commands in your programm. Command exit kill current task with exit code 0.

If you need to get information about one command, Use next syntax: {command} ?. Let's see what will be after typing help ?:

>>> help ?

Command 'help':
  Description:
    'help' is a builtin command that show all commands in refactored case.
  Usage:
    'help' AND 'help ?'

Like this you can get info about every command.

Interest fact: If you will call builder.build() without any registred command in your file, you'll get AttributeError (:

Some usefull things:
None: log( "\nLet's see commands arguments (like sys.argv, but in command):", builder.get_args(), sep="\n", end="\n\n" ) curr_command = builder.get_command("show_uf") log( "If you need to work with some command use 'builder.get_command(command_name: str)'.", "Let's see description and usage of this command:", "Description: " + color.blue + curr_command.description, "Usage: " + color.blue + curr_command.usage, sep="\n", end="\n\n" ) if __name__ == "__main__": builder.build()">
from terminalcmd import (
    builder,
    log,
    color
)


@builder.command(
    short_descrtiption="Show usefull functions and methods.",
    usage="You can type whatever you want, but it must startswith 'show_uf'."
)
def show_uf() -> None:
    log(
        "\nLet's see commands arguments (like sys.argv, but in command):",
        builder.get_args(),
        sep="\n",
        end="\n\n"
    )
    curr_command = builder.get_command("show_uf")
    log(
        "If you need to work with some command use 'builder.get_command(command_name: str)'.",
        "Let's see description and usage of this command:",
        "Description: " + color.blue + curr_command.description,
        "Usage: " + color.blue + curr_command.usage,
        sep="\n",
        end="\n\n"
    )


if __name__ == "__main__":
    builder.build()
Customizing comandlet:
from terminalcmd import builder, log


@builder.command()  # Create some random command.
def hello() -> None:
    """Say "Hello!" to user."""
    log("hello!")


if __name__ == "__main__":
    builder.build(
        comandlet="MaYbE_ChAnGe_CoMaNdLeT -|> ",   # Did you remember comandlet name in examples before?
                                                    # You can change it to your own text.
                                                    #
        notexist_text="THIS command is not exist."  # This text is optional and will be shown if user typed
                                                    # commands that not exist.
    )

Interest point: If you need to have parameter notexist_text like: "This command {and_here_command_name} is not exist." Just add in text this phrase: {command}. (but don't add `f` before text line) and library will replace this phrase with raised exception command name.

You might also like...
Library for building powerful interactive command line applications in Python
Library for building powerful interactive command line applications in Python

Python Prompt Toolkit prompt_toolkit is a library for building powerful interactive command line applications in Python. Read the documentation on rea

prompt_toolkit is a library for building powerful interactive command line applications in Python.
prompt_toolkit is a library for building powerful interactive command line applications in Python.

Python Prompt Toolkit prompt_toolkit is a library for building powerful interactive command line applications in Python. Read the documentation on rea

Python composable command line interface toolkit

$ click_ Click is a Python package for creating beautiful command line interfaces in a composable way with as little code as necessary. It's the "Comm

Python and tab completion, better together.
Python and tab completion, better together.

argcomplete - Bash tab completion for argparse Tab complete all the things! Argcomplete provides easy, extensible command line tab completion of argum

Typer, build great CLIs. Easy to code. Based on Python type hints.
Typer, build great CLIs. Easy to code. Based on Python type hints.

Typer, build great CLIs. Easy to code. Based on Python type hints. Documentation: https://typer.tiangolo.com Source Code: https://github.com/tiangolo/

Python Command-line Application Tools

Clint: Python Command-line Interface Tools Clint is a module filled with a set of awesome tools for developing commandline applications. C ommand L in

Textual is a TUI (Text User Interface) framework for Python using Rich as a renderer.
Textual is a TUI (Text User Interface) framework for Python using Rich as a renderer.

Textual is a TUI (Text User Interface) framework for Python using Rich as a renderer. The end goal is to be able to rapidly create rich termin

Cement is an advanced Application Framework for Python, with a primary focus on CLI

Cement Framework Cement is an advanced Application Framework for Python, with a primary focus on Command Line Interfaces (CLI). Its goal is to introdu

This is a CLI program which can help you generate your own QR Code.

Python-QR-code-generator This is a CLI program which can help you generate your own QR Code. Single.py This will allow you only to input a single mess

Fully Automated YouTube Channel ▶️with Added Extra Features.

Fully Automated Youtube Channel ▒█▀▀█ █▀▀█ ▀▀█▀▀ ▀▀█▀▀ █░░█ █▀▀▄ █▀▀ █▀▀█ ▒█▀▀▄ █░░█ ░░█░░ ░▒█░░ █░░█ █▀▀▄ █▀▀ █▄▄▀ ▒█▄▄█ ▀▀▀▀ ░░▀░░ ░▒█░░ ░▀▀▀ ▀▀▀░

This code will guide you on how you can make your own Twitter Bot.
This code will guide you on how you can make your own Twitter Bot.

This code will guide you on how you can make your own Twitter Bot. This bot retweets, and likes to tweet with a particular word, here Python3.

Its a simple and fun to use application. You can make your own quizes and send the lik of the quiz to your friends.
Its a simple and fun to use application. You can make your own quizes and send the lik of the quiz to your friends.

Quiz Application Its a simple and fun to use application. You can make your own quizes and send the lik of the quiz to your friends. When they would a

This Tool can help enginners and biggener in network, the tool help you to find of any ip with subnet mask that can calucate them and show you ( Availble IP's , Subnet Mask, Network-ID, Broadcast-ID )
This Tool can help enginners and biggener in network, the tool help you to find of any ip with subnet mask that can calucate them and show you ( Availble IP's , Subnet Mask, Network-ID, Broadcast-ID )

This Tool can help enginners and biggener in network, the tool help you to find of any ip with subnet mask that can calucate them and show you ( Availble IP's , Subnet Mask, Network-ID, Broadcast-ID )

Simple AoC helper program you can use to develop your own solutions in python.

AoC-Compabion Simple AoC helper program you can use to develop your own solutions in python. Simply install it in your python environment using pip fr

This is an AI that runs in the terminal. It is a voice assistant that can do common activities and can also help in your coding doubts like

This is an AI that runs in the terminal. It is a voice assistant that can do common activities and can also help in your coding doubts like

Terminal-Video-Player - A program that can display video in the terminal using ascii characters

Terminal-Video-Player - A program that can display video in the terminal using ascii characters

Ever felt tired after preprocessing the dataset, and not wanting to write any code further to train your model? Ever encountered a situation where you wanted to record the hyperparameters of the trained model and able to retrieve it afterward? Models Playground is here to help you do that. Models playground allows you to train your models right from the browser.
Releases(0.8.0)
  • 0.8.0(Jan 4, 2022)

    From 0.7.x added:

    • Parameter name for decorator @builder.command(). Optional, another name instead of this function name. For example, if you need to name commands such as "8ball". • Function name checker. Now if you'll want to add 2 commands with similar function names (or parameter name in decorator) it will raise NameError. BUT, if you'll create 2 functions with similar names, but different parameters name in decorator it'll pass this and console will work correctly. • Comandlet migration. Commandlet migrated from place of parameter in function builder.build() to class variable of builder.commands class. It made for cases if you need to change its value during the console running. Now to access this variable, use builder.commands.comandlet. • Removing colors. Permanent removing colors in processing. We realised it's not important for library. • Removed some builtin functions. Some of sh** like log or prompt deleted, because its was really useless things.

    Source code(tar.gz)
    Source code(zip)
Owner
Dallas
Senior GPyhon Debiloper
Dallas
Python library that measures the width of unicode strings rendered to a terminal

Introduction This library is mainly for CLI programs that carefully produce output for Terminals, or make pretend to be an emulator. Problem Statement

Jeff Quast 305 Dec 25, 2022
Pythonic command line arguments parser, that will make you smile

docopt creates beautiful command-line interfaces Video introduction to docopt: PyCon UK 2012: Create *beautiful* command-line interfaces with Python N

null 7.7k Dec 30, 2022
A simple terminal Christmas tree made with Python

Python Christmas Tree A simple CLI Christmas tree made with Python Installation Just clone the repository and run $ python terminal_tree.py More opti

Francisco B. 64 Dec 27, 2022
Simple cross-platform colored terminal text in Python

Colorama Makes ANSI escape character sequences (for producing colored terminal text and cursor positioning) work under MS Windows. PyPI for releases |

Jonathan Hartley 3k Jan 1, 2023
emoji terminal output for Python

Emoji Emoji for Python. This project was inspired by kyokomi. Example The entire set of Emoji codes as defined by the unicode consortium is supported

Taehoon Kim 1.6k Jan 2, 2023
A thin, practical wrapper around terminal capabilities in Python

Blessings Coding with Blessings looks like this... from blessings import Terminal t = Terminal() print(t.bold('Hi there!')) print(t.bold_red_on_brig

Erik Rose 1.4k Jan 7, 2023
plotting in the terminal

bashplotlib plotting in the terminal what is it? bashplotlib is a python package and command line tool for making basic plots in the terminal. It's a

Greg Lamp 1.7k Jan 2, 2023
Corgy allows you to create a command line interface in Python, without worrying about boilerplate code

corgy Elegant command line parsing for Python. Corgy allows you to create a command line interface in Python, without worrying about boilerplate code.

Jayanth Koushik 7 Nov 17, 2022
Python Fire is a library for automatically generating command line interfaces (CLIs) from absolutely any Python object.

Python Fire Python Fire is a library for automatically generating command line interfaces (CLIs) from absolutely any Python object. Python Fire is a s

Google 23.6k Dec 31, 2022
Cleo allows you to create beautiful and testable command-line interfaces.

Cleo Create beautiful and testable command-line interfaces. Cleo is mostly a higher level wrapper for CliKit, so a lot of the components and utilities

Sébastien Eustace 984 Jan 2, 2023