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.8.tar.gz (23.3 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.8-py3-none-any.whl (27.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: textual_shell-0.9.8.tar.gz
  • Upload date:
  • Size: 23.3 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.8.tar.gz
Algorithm Hash digest
SHA256 054946898cc999f2bb999e1a61b77dea3d98d22287bab5b2b339d9f7fb6f9861
MD5 8d3ead2a43a60b042e64091ec63a5184
BLAKE2b-256 c823910145f5cce0dc036a34c2431759e53f611c836641bd1682cc13728d6e35

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: textual_shell-0.9.8-py3-none-any.whl
  • Upload date:
  • Size: 27.1 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.8-py3-none-any.whl
Algorithm Hash digest
SHA256 a58987638d38de1be0759297583e1a61ac8bd93a0ee0bf09ebec8760920d61fe
MD5 8de999e5bfde6b590ee47dec912817cf
BLAKE2b-256 4c4c75e216e55ea25618e9308c8b61495796f4262c3f8cc2562303654a52fd3b

See more details on using hashes here.

Provenance

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