Module for unified command line handling. More...
Modules |
|
| CDC ACM command line interface transport layer. | |
| Command line interface. configuration | |
| RTT command line interface transport layer. | |
| UART command line interface transport layer. | |
Data Structures |
|
| struct | nrf_cli_cmd_t |
|
CLI command descriptor.
More...
|
|
| struct | nrf_cli_transport_t |
|
Unified CLI transport interface.
More...
|
|
| struct | nrf_cli_ctx_t |
|
CLI instance context.
More...
|
|
| struct | nrf_cli |
|
CLI instance internals.
More...
|
|
| struct | nrf_cli_getopt_option_t |
|
Option descriptor.
More...
|
|
| struct | nrf_cli_getopt_ctx_t |
|
Getopt parser context.
More...
|
|
Macros |
|
| #define | NRF_CLI_CMD (_syntax, _help, _handler) |
|
Initializes CLI command descriptor (
nrf_cli_cmd_t
).
More...
|
|
| #define | NRF_CLI_DEF (name, cli_prefix, transport_iface, cmd_set_tab) |
|
Macro for defining command line interface instance.
More...
|
|
| #define | NRF_CLI_NORMAL VT100_COLOR_WHITE |
| #define | NRF_CLI_INFO VT100_COLOR_GREEN |
| #define | NRF_CLI_WARNING VT100_COLOR_YELLOW |
| #define | NRF_CLI_ERROR VT100_COLOR_RED |
| #define | NRF_CLI_OPT (_optname, _shortname, _type, _help) |
|
Option structure initializer
nrf_cli_getopt_option_t
.
More...
|
|
| #define | NRF_CLI_BUILTIN_CMD_SET |
|
Built-in command set.
More...
|
|
Typedefs |
|
| typedef struct nrf_cli | nrf_cli_t |
|
Alias to
Command Line Interface
. Must be created here to satisfy module declaration order dependencies.
|
|
Enumerations |
|
| enum |
nrf_cli_state_t
{
NRF_CLI_STATE_UNINITIALIZED , NRF_CLI_STATE_INITIALIZED , NRF_CLI_STATE_COLLECT , NRF_CLI_STATE_EXECUTE } |
|
Internal CLI state.
More...
|
|
| enum |
nrf_cli_getopt_type_t
{
NRF_CLI_GETOPT_TYPE_NO_ARG , NRF_CLI_GETOPT_TYPE_REQUIRED , NRF_CLI_GETOPT_TYPE_OPTIONAL } |
|
Option argument type.
More...
|
|
Functions |
|
| ret_code_t | nrf_cli_init ( nrf_cli_t const *p_cli) |
|
Initializes a transport layer and internal CLI state.
More...
|
|
| ret_code_t | nrf_cli_uninit ( nrf_cli_t const *p_cli) |
|
Uninitializes a transport layer and internal CLI state.
More...
|
|
| ret_code_t | nrf_cli_start ( nrf_cli_t const *p_cli) |
|
Start CLI processing.
More...
|
|
| ret_code_t | nrf_cli_stop ( nrf_cli_t const *p_cli) |
|
Stop CLI processing.
More...
|
|
| void | nrf_cli_fprintf ( nrf_cli_t const *p_cli, vt100_color_t color, const char *p_fmt,...) |
|
Printf like function, which send formated data stream to CLI.
More...
|
|
| void | nrf_cli_process ( nrf_cli_t const *p_cli) |
|
Process function, which should be executed when data is ready in transport interface.
More...
|
|
| void | nrf_cli_getopt_ctx_init (size_t argc, char **pp_argv, size_t opt_count, nrf_cli_getopt_option_t const *p_opt, nrf_cli_getopt_ctx_t *p_optctx) |
|
Initializes getopt parser context.
More...
|
|
| int32_t | nrf_cli_getopt ( nrf_cli_getopt_ctx_t *p_optctx) |
|
Standard library getopt/getopt_long method replacement.
More...
|
|
| __STATIC_INLINE const char * | nrf_cli_optarg_get ( nrf_cli_getopt_ctx_t *p_optctx) |
|
Returns handle to current parsed argument (optarg variable replacement).
More...
|
|
| void | nrf_cli_opt_help_show ( nrf_cli_t const *p_cli, nrf_cli_getopt_option_t const *p_opt, size_t opt_len) |
|
Shows command help and options. May be used as default '-h' option handler. It will print actual command help and option description:
More...
|
|
| void | nrf_cli_cmd_list ( nrf_cli_t const *p_cli, size_t argc, char **argv) |
|
List command handler.
More...
|
|
| void | nrf_cli_cmd_clear ( nrf_cli_t const *p_cli, size_t argc, char **argv) |
|
Clear screen command handler.
More...
|
|
| void | nrf_cli_cmd_history ( nrf_cli_t const *p_cli, size_t argc, char **argv) |
|
Show history command handler.
More...
|
|
Detailed Description
Module for unified command line handling.
Macro Definition Documentation
| #define NRF_CLI_BUILTIN_CMD_SET |
Built-in command set.
| #define NRF_CLI_CMD | ( | _syntax, | |
| _help, | |||
| _handler | |||
| ) |
Initializes CLI command descriptor ( nrf_cli_cmd_t ).
- Parameters
-
_syntax Command syntax (for example: "history"). _help Command help string (string used in built-in help command). _handler Handler function.
| #define NRF_CLI_DEF | ( | name, | |
| cli_prefix, | |||
| transport_iface, | |||
| cmd_set_tab | |||
| ) |
Macro for defining command line interface instance.
- Parameters
-
name Instance name. cli_prefix CLI prefix string. transport_iface Transport interface. cmd_set_tab Command set array.
| #define NRF_CLI_ERROR VT100_COLOR_RED |
Error color printf.
| #define NRF_CLI_INFO VT100_COLOR_GREEN |
Info color printf.
| #define NRF_CLI_NORMAL VT100_COLOR_WHITE |
Normal color printf.
| #define NRF_CLI_OPT | ( | _optname, | |
| _shortname, | |||
| _type, | |||
| _help | |||
| ) |
Option structure initializer nrf_cli_getopt_option_t .
- Parameters
-
_optname Option name long. _shortname Option name short. _type Option type nrf_cli_getopt_type_t . _help Option help string.
| #define NRF_CLI_WARNING VT100_COLOR_YELLOW |
Warning color printf.
Enumeration Type Documentation
| enum nrf_cli_state_t |
Function Documentation
| void nrf_cli_cmd_clear | ( | nrf_cli_t const * | p_cli , |
| size_t | argc , | ||
| char ** | argv | ||
| ) |
Clear screen command handler.
- Parameters
-
p_cli CLI instance. argc Number of argv parameters. argv Parameter list.
| void nrf_cli_cmd_history | ( | nrf_cli_t const * | p_cli , |
| size_t | argc , | ||
| char ** | argv | ||
| ) |
Show history command handler.
- Parameters
-
p_cli CLI instance. argc Number of argv parameters. argv Parameter list.
| void nrf_cli_cmd_list | ( | nrf_cli_t const * | p_cli , |
| size_t | argc , | ||
| char ** | argv | ||
| ) |
List command handler.
- Parameters
-
p_cli CLI instance. argc Number of argv parameters. argv Parameter list.
| void nrf_cli_fprintf | ( | nrf_cli_t const * | p_cli , |
| vt100_color_t | color , | ||
| const char * | p_fmt , | ||
| ... | |||
| ) |
Printf like function, which send formated data stream to CLI.
- Parameters
-
p_cli CLI instance. color Printf color. p_fmt Format string. ... List of parameters to print.
| int32_t nrf_cli_getopt | ( | nrf_cli_getopt_ctx_t * | p_optctx | ) |
Standard library getopt/getopt_long method replacement.
- Parameters
-
p_optctx Option parser context.
- Returns
- Parsed option (one letter options are supported by this parser).
- Return values
-
'?' unknown option / no required argument. -1 if all options have been processed. other if option was successfully parsed.
| void nrf_cli_getopt_ctx_init | ( | size_t | argc , |
| char ** | pp_argv , | ||
| size_t | opt_count , | ||
| nrf_cli_getopt_option_t const * | p_opt , | ||
| nrf_cli_getopt_ctx_t * | p_optctx | ||
| ) |
Initializes getopt parser context.
- Parameters
-
argc Number of arguments. pp_argv Argument list. opt_count Number of options. p_opt Option array. p_optctx Option parser context.
| ret_code_t nrf_cli_init | ( | nrf_cli_t const * | p_cli | ) |
Initializes a transport layer and internal CLI state.
- Parameters
-
p_cli CLI instance.
- Returns
- Standard error code.
| void nrf_cli_opt_help_show | ( | nrf_cli_t const * | p_cli , |
| nrf_cli_getopt_option_t const * | p_opt , | ||
| size_t | opt_len | ||
| ) |
Shows command help and options. May be used as default '-h' option handler. It will print actual command help and option description:
Example output:
- Parameters
-
p_cli CLI instance. p_opt Option array. opt_len Option array size.
| __STATIC_INLINE const char* nrf_cli_optarg_get | ( | nrf_cli_getopt_ctx_t * | p_optctx | ) |
Returns handle to current parsed argument (optarg variable replacement).
- Warning
- This call is only valid while nrf_cli_getopt is returning >= 0.
- Parameters
-
p_optctx Option parser context.
- Returns
- Handle to option argument.
| void nrf_cli_process | ( | nrf_cli_t const * | p_cli | ) |
Process function, which should be executed when data is ready in transport interface.
- Parameters
-
p_cli CLI instance.
| ret_code_t nrf_cli_start | ( | nrf_cli_t const * | p_cli | ) |
Start CLI processing.
- Parameters
-
p_cli CLI instance.
- Returns
- Standard error code.
| ret_code_t nrf_cli_stop | ( | nrf_cli_t const * | p_cli | ) |
Stop CLI processing.
- Parameters
-
p_cli CLI instance.
- Returns
- Standard error code.
| ret_code_t nrf_cli_uninit | ( | nrf_cli_t const * | p_cli | ) |
Uninitializes a transport layer and internal CLI state.
- Parameters
-
p_cli CLI instance.
- Returns
- Standard error code.