#include #include #include #include #include "cli.h" using namespace std; static void handle_line(const string & line) { printf("CMD: %s\n", line.c_str()); } string cli_readline() { const char * PROMPT = "> "; char * input = readline(PROMPT); // ctrl-d if (input == NULL) exit(EXIT_SUCCESS); string out = string(input); if (out.size() > 0) add_history(input); free(input); return out; } void cli_main() { while (1) { string cmd = cli_readline(); if (cmd.size() == 0) continue; handle_line(cmd); } }