Skip to main content

A shell widget for textual.

Project description

Textual-Shell

Welcome to the Textual-Shell documentation! This is an addon for the Textual framework.

What is Textual-Shell?

It is a collection of widgets that can be used to build a custom shell application. It draws inspiration from the cmd2 and prompt-toolkit libraries.

Quick Start

Install it with:

pip install textual-shell
import os

from textual.app import ComposeResult
from textual.containers import Grid, Container
from textual.widgets import Header, Footer

from textual_shell.app import BaseShellApp
from textual_shell.commands import Bash, Clear, Help, Jobs, Python, Set
from textual_shell.widgets import (
    Shell,
    CommandList,
    ConsoleLog,
    JobManager,
    SettingsDisplay,
)


class BasicShell(BaseShellApp):
    
    CSS = """
        #app-grid {
            grid-size: 3;
            grid-rows: 1fr;
            grid-columns: 20 2fr 1fr;
            width: 1fr;
        }
    """
    
    theme = 'tokyo-night'

    CONFIG_PATH = os.path.join(os.getcwd(), '.config.yaml')
    
    cmd_list = [Bash(), Clear(), Help(), Jobs(), Python(), Set(CONFIG_PATH)]
    command_names = [cmd.name for cmd in cmd_list]
    
    def compose(self) -> ComposeResult:
        yield Header()
        yield Footer()
        yield Grid(
            CommandList(self.command_names),
            Shell(
                self.cmd_list,
                prompt='prompt <$ '
            ),
            SettingsDisplay(self.CONFIG_PATH),
            Container(),
            ConsoleLog(self.CONFIG_PATH),
            JobManager(),
            id='app-grid'
        )
        
        
if __name__ == '__main__':
    BasicShell().run()

Below is an example config file. The descriptions are used by the help command. The Set command can be used to change these values. The SettingsDisplay widget will load the settings and the corresponding values into a DataTable widget.

Server:
    description: An example server config.
    host:
        description: IP of the server.
        value: 127.0.0.1
    port:
        description: The open port.
        value: 8000
Logging:
    description: Config for logging.
    logdir:
        description: The directory to write log files too.
        value: /var/log/app
    log_format:
        description: The Format for the log records.
        value: '\%(levelname)s\t\%(message)'

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

textual_shell-0.9.91.tar.gz (701.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

textual_shell-0.9.91-py3-none-any.whl (34.9 kB view details)

Uploaded Python 3

File details

Details for the file textual_shell-0.9.91.tar.gz.

File metadata

  • Download URL: textual_shell-0.9.91.tar.gz
  • Upload date:
  • Size: 701.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for textual_shell-0.9.91.tar.gz
Algorithm Hash digest
SHA256 39014612acd2a1a24fb6f83343dda997d9feb3d9e3db45d0f5281e08aed0fb0a
MD5 6d9a2fc9d2f798b2808ac08b490ff66a
BLAKE2b-256 1cddfee35d112f5a39934307d0d7c17a824fc744c8daef2c12c8d041b77720d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for textual_shell-0.9.91.tar.gz:

Publisher: publish-ci.yml on Jason-Lawrence/textual-shell

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file textual_shell-0.9.91-py3-none-any.whl.

File metadata

  • Download URL: textual_shell-0.9.91-py3-none-any.whl
  • Upload date:
  • Size: 34.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for textual_shell-0.9.91-py3-none-any.whl
Algorithm Hash digest
SHA256 d68ee6ff404fd8052c3404ca51fd6b52f2b282ea847b23547a5ad8337bb40f1f
MD5 e7b4f69ad3f973c145d74b25d0b6f915
BLAKE2b-256 49ee220a93ca05872cf52268094a69af686a11af602dc87c869196c96bed5cd3

See more details on using hashes here.

Provenance

The following attestation bundles were made for textual_shell-0.9.91-py3-none-any.whl:

Publisher: publish-ci.yml on Jason-Lawrence/textual-shell

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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