The cli.hpp header provides a convenience include / wrapper around
daniele77/cli <https://github.com/daniele77/cli>_. It also exposes cli's
include folder, so including "cli.hpp" is completely equivalent to including
<cli/cli.h> - but you can additionally include other files from
<cli/>. It also provides a few conveniences:
- a
espp::Cliclass which inherits fromcli::CliSessionand has a near-identical implementation ascli'sCliFileSesson, with the exception that it explicitly reads character by character instead of line by line and prints out the characters as they are being input, and - a static
espp::Cli::configure_stdin_stdout()function which sets up the esp UART to enable blockingstd::cinread, which is needed forstd::cinto work (and therefore - currently - forclito work). This function is automatically called by theespp::Cliconstructor, but it can also be called manually without needing to create aespp::Cliobject if you wish to simply use thestd::cinand related functions. - a
espp::LineInputclass which provides support for an interactive input system which can optionally have history with navigation. It allows for getting the user input as an arbitrary input string while enabling some keyboard movement and editing commands. Theespp::Cliuses theespp::LineInputclass internally to handle the input aspects of the Cli, but theespp::LineInputclass can be re-used anywhere you want to get one or more lines of user input in a reusable way. Note that if you use it in another class / outside theespp::Cliclass, you will need to call theespp::Cli::configure_stdin_stdout()as mentioned above.
The Cli and associated LineInput classes support:
- ctrl+a (move to beginning of line)
- ctrl+e (move to end of line)
- ctrl+n (move up a line / previous input history)
- ctrl+p (move down a line / next input history)
- ctrl+k (delete from the cursor to the end of the line)
- ctrl+b (move the cursor back one character)
- ctrl+f (move the cursor forward one character)
- ctrl+l (clear the screen)
Please see the documentation for the cli submodule <https://github.com/daniele77/cli>_ if you have any questions about usage
beyond the examples provided here.
The example shows how to use the Cli component to setup and run a
command line interface (CLI) on the ESP.