TGViewer
C++ - Reddit C++ - Reddit @r_cpp · 229 subscribers
Post #24576 23
Header-only library for creating simple text-based command interpreters

Hi all,

I made a small header-only library called conco ("console commands") designed to make building simple command interpreters, REPLs, or Quake-like game consoles trivial.

The core idea is to take a raw string like add 10 20 and automatically dispatch it to a C++ function like int add(int x, int y);. The library handles tokenization, type conversion, argument passing and result stringification for you.

You can bind regular functions, capturing lambdas or member functions as your commands. There is no global state and no dynamic memory allocations. The library is well suited for embedded development, where creating text-based debug interfaces over UART/serial port might come handy.

Basic example:


void logenable() { ... }

int sum(int a, int b) { return a + b; }

int main()
{
// List of available commands
const conco::command commands[] = {
{ log
enable, "log.enable;Enable logging" },
{ sum, "sum;Sum of two integers" }
};

// Calls log_enable
conco::execute(commands, "log.enable");

char buffer256 = { 0 };

// Calls sum(123, 456), writes stringified result to buffer
conco::execute(commands, "sum 123 456", buffer);
std::println("{}", buffer); // Outputs: 579
}

I would love to hear your feedback or roast of the implementation! Check out the GitHub repository link here:

https://github.com/P-i-N/conco

Cheers!

https://redd.it/1pwvui8
@r_cpp
GitHub GitHub - P-i-N/conco: C++ header only library for building REPL-like interfaces C++ header only library for building REPL-like interfaces - P-i-N/conco
More from @r_cpp
  1. Oct 8, 2026Profiles for simplicity and guarantees - Bjarne Stroustrup - CppCon 2026 https://youtu.be/…
  2. Oct 8, 2026How to Fix autoconf-style Configuration Probing https://build2.org/blog/fix-autoconf.xhtml…
  3. Oct 8, 2026owl – a header-only C++23 HTTP framework where route patterns and handler extractors are c…
  4. Oct 8, 2026Removed by Reddit Removed by Reddit on account of violating the [content policy. ] https:/…
  5. Oct 8, 2026Is there a way to search across all P and N papers throughout standardization history? It…
  6. Oct 8, 2026CppCast Episode 412 : Safety and Interoperability with Rust and C++ https://cppcast.com/sa…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →