Command line interface

group CLI

Command line interface.

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


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

Printf handle for CLI.

  • [in] format: string format

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

CLI entriy function.

  • [in] cliprintf: Printf handle callback

  • [in] argc: Number of arguments

  • [in] argv: Pointer to pointer to arguments


const cli_command_t *cli_lookup_command(char *command)

Find the CLI command that matches the input string.


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

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

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

CLI auto completion function.

  • [in] cliprintf: Pointer to CLI printf function

  • [in] cmd_buffer: CLI command buffer

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

  • [in] print_options: 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.


true when new commands where succesfully added, else false

  • [in] commands: Pointer to commands table

  • [in] num_of_commands: Number of new commands

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