This module allows to create and handle a simple command line interface (CLI) with a user-defined command set. You can use it in examples where more than button/LED user interaction is required. This module can be considered a simplified Unix-like command line interface with these features:
- Command completion support with the Tab key
-
Built-in
list,clear, andhistorycommands - Viewing the recently executed commands using the Up/Down keys
- Support for ANSI escape codes for cursor control and color printing (VT100)
The module can be connected to any transport. At this point, the following transport layers are implemented:
- USB CDC ACM
- UART
- RTT
Use the NRF_CLI_DEF macro to create an instance of the CLI. The following code shows a simple use case of this library:
Every user-defined command can have short options and long options:
-
Short option format: "-x", where
xis a letter. -
Long option format: "--xyz", where
xyzis a word (without whitespaces).
Every option can be followed by an argument. Macro NRF_CLI_OPT defines the options:
- Syntax long
- Syntax short
- Following arguments
- Help string
Parsing of options works similarly to the getopt_long library :
The following code shows how command options should be processed:
For API documentation of this library, refer to Command Line Interface .
For a usage example, refer to Command Line Interface (CLI) Example .