Command line interface

group CLI

Command line interface.

Functions to initialize everything needed for command line interface (CLI).

Typedefs

typedef void cli_printf(const char *format, ...)

Printf handle for CLI.

Param format

[in] string format

typedef void cli_function(cli_printf cliprintf, int argc, char **argv)

CLI entriy function.

Param cliprintf

[in] Printf handle callback

Param argc

[in] Number of arguments

Param argv

[in] Pointer to pointer to arguments

Functions

const cli_command_t *cli_lookup_command(char *command)

Find the CLI command that matches the input string.

Parameters

command[in] pointer to command string for which we are searching

Returns

pointer of the command if we found a match, else NULL

void cli_tab_auto_complete(cli_printf cliprintf, char *cmd_buffer, uint32_t *cmd_pos, bool print_options)

CLI auto completion function.

Parameters
  • cliprintf[in] Pointer to CLI printf function

  • cmd_buffer[in] CLI command buffer

  • cmd_pos[in] pointer to current courser postion in command buffer

  • print_options[in] additional prints in case of double tab

bool cli_register_commands(const cli_command_t *commands, size_t num_of_commands)

Register new CLI commands.

Parameters
  • commands[in] Pointer to commands table

  • num_of_commands[in] Number of new commands

Returns

true when new commands where succesfully added, else false

void cli_init(void)

CLI Init function for adding basic CLI commands.

struct cli_command_t
#include <cli.h>

CLI command structure.

Public Members

const char *name

Command name

const char *help

Command help

cli_function *func

Command function

struct cli_commands_t
#include <cli.h>

List of commands.

Public Members

const cli_command_t *commands

Pointer to commands

size_t num_of_commands

Total number of commands