CLI v1.0.0
Custom cli console for creating commands executable at runtime
Loading...
Searching...
No Matches
Classes | Public Member Functions | Public Attributes | List of all members
cli::Console Class Reference

Console represents the customisable console. More...

#include <cli.hpp>

Classes

class  Node
 

Public Member Functions

Node & operator[] (const std::string &key)
 Used to add a new command.
 
void Run ()
 Starts the custom console.
 
void Run (std::string filename)
 Starts the custom console and executes commands from a file.
 

Public Attributes

bool stop = false
 Manages if the main loop should stop.
 
struct { 
 
   bool   newLineAutoComplete = true 
 Sets the style of autocomplete. More...
 
   int   histSize = 10 
 Sets the size of history. More...
 
} settings 
 Console settings.
 

Detailed Description

Console represents the customisable console.

Console sets up raw mode for the console, manages settings, autocomplete when typing commands, and executing stored commands.

Member Function Documentation

◆ operator[]()

Console::Node & cli::Console::operator[] ( const std::string &  key)

Used to add a new command.

Can be chained togehter with Console::Node::operator[] to add more complex commands.

Console console;
//create a command "command set histSize";
console["console"]["set"]["histSize"].function = [](){};
Console represents the customisable console.
Definition cli.hpp:21
Parameters
keyCommand name

◆ Run() [1/2]

void cli::Console::Run ( )

Starts the custom console.

Sets up raw mode for custom key functionality and begins the main loop.\

Here is the caller graph for this function:

◆ Run() [2/2]

void cli::Console::Run ( std::string  filename)

Starts the custom console and executes commands from a file.

Like Run() but also executes commands from a file. Useful when a script file is wanted.

if (argc == 1)
console.Run();
else
console.Run(argv[1]);
Here is the call graph for this function:

Member Data Documentation

◆ histSize

int cli::Console::histSize = 10

Sets the size of history.

History can be accessed with Up/Down arrow keys.

◆ newLineAutoComplete

bool cli::Console::newLineAutoComplete = true

Sets the style of autocomplete.

When true creates a new line when autocompleating Cisco-style. When false keeps the autocomplete in the same line like in a terminal.

◆ stop

bool cli::Console::stop = false

Manages if the main loop should stop.

Set to true if you want to stop the console from running.


The documentation for this class was generated from the following files: