9

GitHub - reeflective/console: Closed-loop application library for Cobra commands...

 1 year ago
source link: https://github.com/reeflective/console
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Console

Closed-loop application library for Cobra commands

(Menus, oh-my-posh prompts, bells and whistles, easy to use)

Console is an all-in-one console application library built on top of a readline shell and using Cobra commands. It aims to provide users with a modern interface at at minimal cost while allowing them to focus on developing their commands and application core: the console will then transparently interface with these commands, and provide the various features below almost for free.

Features

Menus & Commands

  • Bind cobra commands to provide the core functionality.
  • Multiple menus with their own command tree, prompt engines and special handlers.
  • All cobra settings can be modified, set and used freely, like in normal CLI workflows.
  • Bind handlers to special interrupt errors (eg. CtrlC/CtrlD), per menu.

Shell interface

  • Shell interface is powered by a readline instance.
  • All features of readline are supported in the console. It also allows the console to give:
  • Configurable bind keymaps, with live reload and sane defaults, and system-wide configuration.
  • Out-of-the-box, advanced completions for commands, flags, positional and flag arguments.
  • Provided by readline and carapace: automatic usage & validation command/flags/args hints.
  • Syntax highlighting for commands (might be extended in the future).

Others

  • Support for an arbitrary number of history sources, per menu.
  • Support for oh-my-posh prompts, per menu and with custom configuration files for each.
  • Also with oh-my-posh, write and bind application/menu-specific prompt segments.

Documentation

You can install and use the example application console. This example application will give you a taste of the behavior and supported features. The following documentation is also available in the wiki:

Showcase

console

Status

The library is in a pre-release candidate status:

  • Although quite simple and small, it has not been tested heavily.
  • There are probably some features/improvements to be made.

Please open a PR or an issue if you wish to bring enhancements to it. Other contributions, as well as bug fixes and reviews are also welcome.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK