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
A CLI tool to build beautiful command-line interfaces with type validation.

Piou A CLI tool to build beautiful command-line interfaces with type validation. It is as simple as from piou import Cli, Option cli = Cli(descriptio

Julien Brayere 310 Dec 07, 2022
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 8.1k Dec 30, 2022
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

Will McGugan 17k Jan 02, 2023
A minimal and ridiculously good looking command-line-interface toolkit

Proper CLI Proper CLI is a Python package for creating beautiful, composable, and ridiculously good looking command-line-user-interfaces without havin

Juan-Pablo Scaletti 2 Dec 22, 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 01, 2023
Python library to build pretty command line user prompts ✨Easy to use multi-select lists, confirmations, free text prompts ...

Questionary ✨ Questionary is a Python library for effortlessly building pretty command line interfaces ✨ Features Installation Usage Documentation Sup

Tom Bocklisch 990 Jan 01, 2023
A drop-in replacement for argparse that allows options to also be set via config files and/or environment variables.

ConfigArgParse Overview Applications with more than a handful of user-settable options are best configured through a combination of command line args,

634 Dec 22, 2022
A cross platform package to do curses-like operations, plus higher level APIs and widgets to create text UIs and ASCII art animations

ASCIIMATICS Asciimatics is a package to help people create full-screen text UIs (from interactive forms to ASCII animations) on any platform. It is li

3.2k Jan 09, 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
A fast, stateless http slash commands framework for scale. Built by the Crunchy bot team.

Roid 🤖 A fast, stateless http slash commands framework for scale. Built by the Crunchy bot team. 🚀 Installation You can install roid in it's default

Harrison Burt 7 Aug 09, 2022
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

Andrey Kislyuk 1.1k Jan 08, 2023
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
Rich is a Python library for rich text and beautiful formatting in the terminal.

Rich 中文 readme • lengua española readme • Läs på svenska Rich is a Python library for rich text and beautiful formatting in the terminal. The Rich API

Will McGugan 41.4k Jan 02, 2023
Terminalcmd - a Python library which can help you to make your own terminal program with high-intellegence instruments

Terminalcmd - 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.

Dallas 0 Jun 19, 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

7.7k Dec 30, 2022
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 02, 2023
Humane command line arguments parser. Now with maintenance, typehints, and complete test coverage.

docopt-ng creates magic command-line interfaces CHANGELOG New in version 0.7.2: Complete MyPy typehints - ZERO errors. Required refactoring class impl

Jazzband 108 Dec 27, 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 02, 2023
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

prompt-toolkit 8.1k Jan 04, 2023