vlandeiro/yakari: Yakari: an interactive command building tool
December 21, 2024

vlandeiro/yakari: Yakari: an interactive command building tool

Transform complex command-line interfaces into guided interactive experiences. Yakari helps users build commands step-by-step, making CLI tools more accessible and user-friendly.

usage: ykr [-h] [-d] [-n] command_name

positional arguments:
  command_name   Name of the command to execute

options:
  -h, --help     show this help message and exit
  -d, --dry-run  If toggled, Yakari only prints the command rather than running it.
  -n, --native   When toggled, run the command in the original shell instead of
                 within the Yakari TUI.

and UV rays:

uvx --from yakari ykr demo

A demo will be launched showing the different types or parameters and commands supported by Yakari. This demo only runs echo command so it can be used safely anywhere.

uvx --from yakari ykr git

A terminal user interface (TUI) with basic functionality will be launched git feature. The video below shows how to use this TUI to:

  • list branches
  • Create and check out a new demo branch
  • Add files and create submissions
  • Check the git log to verify that the commit was created
  • delete demo branch

output.mp4


Try this in a git repository!

Yakari is an interactive command menu that makes it easy to execute complex commands. Think of it as a command launcher where you type shortcuts instead of memorizing full commands.

When you launch Yakari, you will see a menu of available options. Each menu item has a shortcut (shown on the left). Enter the shortcut to select it:

  • Commands (things you can run)
  • Parameters (options you can set)
  • Submenu (with more options inside)

Other important keyboard shortcuts allow you to interact with the TUI:

key action
ctrl+q Cancel/Exit
backspace key delete/return
tab autocomplete
Ctrl+R Switch results
ctrl+l clear results
Ctrl+E Switch editing mode


example: In the git branch menu, enter - Highlight -f and -t parameter and dim other entries.

Parameters are options you can set. There are two modes for handling them:

Normal mode (default):

  • Select a parameter to turn it on/off
  • Great for quick switching e.g. --verbose

Edit mode (press ctrl+e switch):

  • Select a parameter to edit its value
  • Great for editing named parameters with existing values

Yakari publishes to PyPI:

# Using pip
pip install yakari

# Using uv
uv tool install yakari

A command menu is a TOML configuration file that defines a hierarchical interface for executing commands. It allows you to:

  • Organize related commands into menus
  • Define reusable parameters
  • Create interactive prompts for command values

Install the new menu by copying the corresponding TOML file into
$HOME/.config/yakari/menus. If you’re interested in creating your own menu, check out the dedicated menu Readme from yakari-menus.

hint

Yakari comes with some Predefined menu
You can directly use ykr (For example ykr git).

  • Interactive command building
  • Contextual help and instructions
  • Use with existing CLI tools
  • Command history across executions
  • Static and dynamic suggestions
  • Use streaming output for in-place command execution and support for interactive commands
  • Supported parameter types:
    • flag parameter
    • single value parameter
    • multiple choice argument
    • Password parameters
    • Many-valued argument
  • New parameter type:
  • Support environment variables

The name comes from a Swiss comic character who can talk to animals. Likewise, the tool helps users communicate with command-line programs more naturally by turning daunting command structures into guided menus.

2024-12-18 22:54:56

Leave a Reply

Your email address will not be published. Required fields are marked *