TUIview [tv]

A TUI for every CLI 📺

GitHub tag (with filter) GitHub last commit (branch) GitHub Repo stars License

TUIview [tv]

TUIview [tv] allows you to create Textual User Interfaces (TUIs) for command-line interfaces (CLIs) that do not provide their own TUI.

By prefixing any supported CLI command with the tv command -- tv <program> -- you can interact with a TUI form to interactively build and execute CLI commands for <program>.

Install

$ pipx install tuiview

or

$ pip install tuiview

Use

Prefix your command with tv to invoke the TUI for the given CLI app:

tv git

You can even specify subcommands and arguments, which will filter and pre-populate the TUI form.

tv git commit -m 'Hello' -m 'World'

Which CLI apps are available?

Call TUIview (tv) without arguments to view all available apps:

$ tv
________________________________________

Helpful Parameters:
  --help, -h  Show this help message.
  ...

Commands:
    git
    grep
    pastel
    rsync
    ...

How does it work?

  • TUIview contains a collection of pre-defined, curated TUI interfaces for each CLI application.

  • These curated TUI interfaces -- termed "TV Programs" -- are defined in YAML files, or in Python files that implement an Argparse ArgumentParser.

  • argparse-tui is the Python package that enables this capability. Using argparse-tui, Python's Argparse can serve as a declarative DSL for generating a TUI form.

TV Programs

TV Program can be defined in YAML or JSON:

echo.yaml

'echo':
  description: 'Print text'
  arguments:
    'message':
      pos: true
      nargs: '+'
    'n':
      flags: ['-n']
      action: 'store_true'
      help: 'no trailing newline'

Execute the program file with tv:

$ tv echo.yaml -n Hello World

TV Programs

TV Programs can also be defined in Python files that implement an Argparse ArgumentParser.

For example, to define a TV Program for the echo command:

echo.py

import argparse
parser = argparse.ArgumentParser(prog="echo", description="Print text.")
parser.add_argument("message", nargs="+")
parser.add_argument("-n", action="store_true", help="no trailing newline")

Execute the program file with tv:

$ tv echo.py -n Hello World

Import & Edit a TV Program

TUIview can import a program file so that it can be invoked globally.

$ tv --import echo.yml

The file echo.yml now exists at ~/.tuiview/echo.yml where it can be invoked from anywhere, just like a native TV program:

$ tv echo Hello World

To edit a program file, pass the command name to tv:

$ tv --edit echo

When editing a native program, the program file is imported to the TV program directory and opened for editing.

Contributing

TUIview is a small program for running and managing these TV Program files.

The real work -- the real value -- is in the quantity and quality of the program files. If you want to improve TUIview by contributing and improving TV Programs, PRs are welcome 🤙

Pro tip: Given a the help text output from your CLI app of choice, ChatGPT is decent at providing an Argparse implementation of it.

Related Projects

This is the library that provides the TUIview magic ✨

This is the library that provides the TUIview CLI.

End.

Brought to you by...

![bg contain right:33%](https://img.fresh2.dev/1691603513_6110801a432.png)