All Projects → chewax → Ginseng

chewax / Ginseng

Licence: mit
C++ REPL Tool Builder

Programming Languages

cpp
1120 projects
cpp11
221 projects

Projects that are alternatives of or similar to Ginseng

Colorette
Easily set the color and style of text in the terminal.
Stars: ✭ 1,047 (+1510.77%)
Mutual labels:  cli, terminal, console
Crossline
A small, self-contained, zero-config, MIT licensed, cross-platform, readline and libedit replacement.
Stars: ✭ 53 (-18.46%)
Mutual labels:  cli, terminal, console
Pulsemixer
CLI and curses mixer for PulseAudio
Stars: ✭ 441 (+578.46%)
Mutual labels:  cli, terminal, console
Tqdm
A Fast, Extensible Progress Bar for Python and CLI
Stars: ✭ 20,632 (+31641.54%)
Mutual labels:  cli, terminal, console
Video To Ascii
It is a simple python package to play videos in the terminal using characters as pixels
Stars: ✭ 960 (+1376.92%)
Mutual labels:  cli, terminal, console
Stig
TUI and CLI for the BitTorrent client Transmission
Stars: ✭ 360 (+453.85%)
Mutual labels:  cli, terminal, console
Termtools
Customize your terminal using JavaScript. With themes, extra alias and functions, we combine the power from both JavaScript and Bash.
Stars: ✭ 42 (-35.38%)
Mutual labels:  cli, terminal, console
Tty Markdown
Convert a markdown document or text into a terminal friendly output.
Stars: ✭ 275 (+323.08%)
Mutual labels:  cli, terminal, console
Radian
A 21 century R console
Stars: ✭ 878 (+1250.77%)
Mutual labels:  cli, terminal, console
Tui Consolelauncher
Linux CLI Launcher for Android
Stars: ✭ 861 (+1224.62%)
Mutual labels:  cli, terminal, console
Consola
Elegant Console Logger for Node.js and Browser 🐨
Stars: ✭ 3,461 (+5224.62%)
Mutual labels:  cli, terminal, console
Langterm
🕹️ WebGL-based VT220 emulator, made as a learning example and frontend for a text adventure
Stars: ✭ 35 (-46.15%)
Mutual labels:  cli, terminal, console
Nestjs Console
A nestjs module that provide a cli to your application.
Stars: ✭ 284 (+336.92%)
Mutual labels:  cli, terminal, console
Yaspin
A lightweight terminal spinner for Python with safe pipes and redirects 🎁
Stars: ✭ 413 (+535.38%)
Mutual labels:  cli, terminal, console
Chalk
🖍 Terminal string styling done right
Stars: ✭ 17,566 (+26924.62%)
Mutual labels:  cli, terminal, console
Progressbar
Terminal-based progress bar for Java / JVM
Stars: ✭ 625 (+861.54%)
Mutual labels:  cli, terminal, console
S Tui
Terminal-based CPU stress and monitoring utility
Stars: ✭ 2,825 (+4246.15%)
Mutual labels:  cli, terminal, console
Laravel Zero
A PHP framework for console artisans
Stars: ✭ 2,821 (+4240%)
Mutual labels:  cli, terminal, console
Python Progressbar
Progressbar 2 - A progress bar for Python 2 and Python 3 - "pip install progressbar2"
Stars: ✭ 682 (+949.23%)
Mutual labels:  cli, terminal, console
Wonders
🌈 Declarative JavaScript framework to build command-line applications.
Stars: ✭ 34 (-47.69%)
Mutual labels:  cli, terminal, console

Logo


Contributors Issues Build Status Last Commit MIT License

Table of Contents

About The Project

Ginseng

This is a lightweight header only library that will help you build REPL tools faster. It is based on the ncurses library. Before proceeding with installation please make sure you have this library installed.

Getting Started

To get a local copy up and running follow these simple steps.

Prerequisites

  1. c++11
  2. ncurses

Installation

  1. Clone the Ginseng into repo into your libs
git clone https://github.com/chewax/Ginseng.git

Usage

Basic usage.

#include "Ginseng.h"

int main() 
{
	Ginseng repl;
	repl.start();
	return 0;
}

This example will setup a basic REPL tool with empty commands. At this stage you can use commands such as help or exit.

Configuring Delimiter.

You can setup your own delimiter using the first parameter for such thing.

#include "Ginseng.h"

int main() 
{
	Ginseng repl("$delim>");
	repl.start();
	return 0;
}

Configuring custom greet and farewell functions.

Ginseng will let you handle certain events in your REPL. Such is the case of (obviously) commands. But also you can set up handlers for greet and goodbye if you wish.

#include "Ginseng.h"

int main() 
{
	
	Ginseng repl("$test>",
	  [&repl]() {
	    repl.println("WELCOME TO MY AWESOME RELP!");
	    repl.println("Type \"help\" to start");
	    repl.println("");
	    repl.println("HAVE FUN!");
	  },
	  [&repl]() {
	    repl.println("BYE!");
	  });
	repl.start();
	return 0;
}

Setting up commands.

Commands can be created using add_command function. Such function receives 3 paramenters Namely:

  1. Command Name
  2. Command Handler (or Callback)
  3. Command Help Struct

Help struct is used to let Ginseng know how to print help information. Help struct is just 2 strings one for the argument list and one for the actual description.

// Help(std::string desc, std::string args);
Help hello_help("Says hello back at you", "[name]");

Callback function will be called passing a vector contining the list of arguments (including the command name) collected from the console. Vector will contain at least 1 element (namely: the command name).

Callback function is required to return a success/fail return type Exit. Possible values are

	[ SUCCESS|INVALID_ARGUMENTS|ERROR ]
	//eg: Exit::SUCCESS

This is important to let Ginseng know of the result of the command.

Here is the final code for a more advanced setup with "Hello" Command:

#include "Ginseng.h"

int main()
{
  //Create Ginseng REPL
  Ginseng repl(
      "$test>",
      [&repl]() {
        repl.println("WELCOME TO MY AWESOME RELP!");
        repl.println("Type \"help\" to start");
        repl.println("");
        repl.println("HAVE FUN!");
      },
      [&repl]() {
        repl.println("BYE!");
      });

  // Create Help struct for hello command
  Help hello_help("Says hello back at you", "[name]");

  // Add "hello" command to the REPL
  repl.add_command(
      "hello",
      [&repl](std::vector<std::string> args) -> int {
        if (args.size() < 2)
          return Exit::INVALID_ARGUMENTS;
        repl.printf("HELLO %s\n", args[1].c_str());
        return Exit::SUCCESS;
      },
      hello_help);

  repl.start();
  return 0;
}

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

LinkedIn Twitter Follow
Project Link: https://github.com/chewax/Ginseng

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].