Skip to main content

tty-utility

Tty-utility is an console for python programs

Install

Python pip

pip install tty-utility

Python direct install

  • Download archive & extract
  • python setup.py install

Usage

Imports

from ttyutility import Command

Import an Command base class

from ttyutility import Console

Import an Console class

Command class

Command class is an base class for new command. It's necessary inherit of Command.

configure

The configure method register an command in system. But for register arguments of command, it's necessary of reimplement method.

In method, call parent method first. Used add_argument method for register a new argument.

add_argument

Add new argument of command :

  • name of argument
  • number of parameters (0 by default)
  • type of parameter (str by default)
  • help text (not help text by defaut)

add_argument is used in configure method.

execute

execute method, run the treatment of command and arguments.

Console class

Console class is an console manager.

For manage console: used register, for register all of commands, and run for run console.

register

Register a new command in console system.

  • Name of command
  • Instance of Command class or herited of class

run

Run the console system.

  • List or arguments (None by default)

The list of arguments (tuple), simulate a command line.

Example

from ttyutility import Command, Console


class NewCommand(Command):
    test = "ds"

    def configure(self, name: str, parser, prog: str = None, help: str = None):
        super(NewCommand, self).configure(name, parser, prog, help)

        self.add_argument('tt')

    def execute(self, args: dict):
        if args['tt']:
            print(args)


console = Console()
console.register('test', NewCommand())
console.run()

Declaration of new command, add argument in configure method and treatment in execute method.

Create instance of console, register new command and run console.

Credits

Package developed by Christophe Daloz - De Los Rios christophedlr@gmail.com

Release files for tty-utility 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tty-utility 1.0.0
File Size Uploaded
tty-utility-1.0.0.tar.gz 3.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tty-utility 1.0.0
File Interpreter ABI Platform
tty_utility-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size:9.5 kB

Release files / tty-utility-1.0.0.tar.gz

Download URL tty-utility-1.0.0.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
bc3996fa418f603043c3e2212ec43f1af9a2d0706c70f64908b84309bcd8c774
BLAKE2b-256 checksum
How to use checksums
89464f7a41a8296df4e8a645dc960561fdd4e3f2a762cdb8fb86cd4feef49d3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

Release files / tty_utility-1.0.0-py3-none-any.whl

Download URL tty_utility-1.0.0-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0e98a97bca9d07820d887e1a35467e3aa948bef959afde70e44357d9bade4835
BLAKE2b-256 checksum
How to use checksums
bd2ed35295bd4a8cadcdaae5b886673c67ca4271b0958d49ae1d31ffa1a44b54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page