TTY OV  1
A cross platform python terminal
Loading...
Searching...
No Matches
TTY OV

tty_ov

PyPI - Python Version PyPI - Implementation PyPI - Wheel PyPI - Version PyPI - Downloads PyPI - License Execution status GitHub Workflow Status (with event) GitHub repo size GitHub Repo stars GitHub commit activity (branch) GitHub last commit (branch)

Static Badge

Take a look

This project now has automated documentation that gets generated, this manually written one will remain for legacy reasons, but you can now take a look at the automatic documentation here: https://hanra-s-work.github.io/tty_ov/

Description

Table of Content

  1. tty_ov
  2. Description
  3. Table of Content
  4. Installation
    1. Using pip
    2. Using python
  5. Usage
    1. Running as a script
    2. Importing
    3. Initialising
    4. Using built-in commands
  6. Features
    1. Core Commands
    2. Advanced Features
    3. Extensibility
  7. Documentation
  8. Author
  9. Version

Installation

Using pip

pip install -U tty_ov

Using python

Under Windows:

py -m pip install -U tty_ov

Under Linux/Mac OS:

python3 -m pip install -U tty_ov

Usage

Running as a script

You can run tty_ov directly as a script to start an interactive terminal session:

python -m tty_ov

This will launch the interactive TTY interface where you can execute commands.

Importing

from tty_ov import TTY

Initialising

The generic class is: TTY(err: int, error: int, success: int, colour_lib: ColouriseOutput, ask_question: AskQuestion, colours: Dict, colourise_output: bool = True)

For your convenience, you can initialize the class with default parameters:

from tty_ov import TTY, ColouriseOutput, AskQuestion
ERR = 84
ERROR = ERR
SUCCESS = 0
COLOUR_LIB = ColouriseOutput()
ASK_QUESTION = AskQuestion()
CONSTANTS = {
"default": "0A",
"prompt": "0B",
"error": "0C",
"success": "03",
"info": "0D",
"reset": "rr",
"help_title_colour": "0E",
"help_command_colour": "0A",
"help_description_colour": "0F",
"env_term_colour": "09",
"env_shell_colour": "03",
"env_definition_colour": "0B",
"session_name_colour": "0D"
}
COLOURISE_OUTPUT = True
tty_instance = TTY(
ERR,
ERROR,
SUCCESS,
COLOUR_LIB,
ASK_QUESTION,
CONSTANTS,
COLOURISE_OUTPUT
)
tty_instance.load_basics()
tty_instance.mainloop("Custom session")
tty_instance.unload_basics()

Using built-in commands

Once initialized, you can use various built-in commands programmatically. Here are some examples:

File System Navigation

# Change directory
tty_instance.change_directory(["/path/to/directory"])
# Print working directory
tty_instance.pwd([])
# List files
tty_instance.bind_ls([])

Environment Management

# Display environment variables
tty_instance.env([])
# Set an environment variable
tty_instance.setenv(["MY_VAR", "my_value"])
# Unset an environment variable
tty_instance.unsetenv(["MY_VAR"])

Running External Commands

# Run a system command
tty_instance.run_command(["echo", "Hello World"])

Session Management

# Change session name
tty_instance.process_session_name(["new_session_name"])
# Show command history
tty_instance.show_history([])

Features

tty_ov includes a variety of built-in commands and features:

Core Commands

  • File System Navigation: cd, pwd, ls (with colorized output)
  • File Operations: mkdir, touch, rm, rmdir
  • System Interaction: run (execute external commands), super_run (run with elevated privileges)
  • Environment Management: env, env++, setenv, unsetenv
  • Session Management: session_name, history
  • Information: version, author, client, is_admin
  • Utilities: hello_world, ? (display last status code)

Advanced Features

  • Piping Support: Chain commands using pipes
  • Argument Input: Full support for command-line arguments
  • Colorized Output: Configurable color schemes for different output types
  • Command History: Track and display previous commands
  • Help System: Built-in help for all commands
  • Auto-completion: Tab completion for commands
  • Multi-command Execution: Execute multiple commands in sequence
  • Comment Support: Ignore lines starting with comment tokens

Extensibility

  • Custom Commands: Import additional functions into the shell
  • Session Management: Multiple named sessions
  • Configurable Tokens: Customize command separators and comment tokens

Documentation

Comprehensive Doxygen-generated documentation is available online at https://hanra-s-work.github.io/tty_ov/. This includes detailed API references, class documentation, and usage examples.

To generate the documentation locally, navigate to the doxygen_generation directory and run the provided scripts.

Author

This module was written by (c) Henry Letellier Attributions are appreciated.

Version

The current version is 1.0.0

An easy way to display the version is:

import tty_ov
print(f"Version : {tty_ov.__version__}")