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 Clear, Help, Set, Jobs
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')
    HISTORY_LOG = os.path.join(os.environ.get('HOME', os.getcwd()), '.shell_history.log')
    
    cmd_list = [Clear(), Help(), Set(CONFIG_PATH), Jobs()]
    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)'

TODO:

  • write documentation on Commands
  • write documentation on shell key binds
  • write documentation on widgets
  • write documentation on jobs.

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.85.tar.gz (27.8 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.85-py3-none-any.whl (31.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: textual_shell-0.9.85.tar.gz
  • Upload date:
  • Size: 27.8 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.85.tar.gz
Algorithm Hash digest
SHA256 78f90b8f6cba4e46861916f69f690b44c4735f9ce95f79402e625fc8174f4714
MD5 4f4e9ca55f58d323a53bfe98f3dbb777
BLAKE2b-256 0c4b1b5846f5b8545a4ecdcb659e9dae88e3481305a7f0e69ffe4b9d4c5cd50a

See more details on using hashes here.

Provenance

The following attestation bundles were made for textual_shell-0.9.85.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.85-py3-none-any.whl.

File metadata

  • Download URL: textual_shell-0.9.85-py3-none-any.whl
  • Upload date:
  • Size: 31.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.85-py3-none-any.whl
Algorithm Hash digest
SHA256 a74a117dde10da87e56cefff398aef1e5039fd3068de5d8cefb1223cccb7005e
MD5 21f796f4b4c43690dd564c11caa3fa3f
BLAKE2b-256 fd9c3151694068f974d0fe129d5af503ee10a60de74649944ed936ec9e569bda

See more details on using hashes here.

Provenance

The following attestation bundles were made for textual_shell-0.9.85-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