Command metadata and helpers. More...
#include <furi.h>#include <toolbox/pipe.h>#include <lib/flipper_application/flipper_application.h>Go to the source code of this file.
Data Structures | |
| struct | CliCommandDescriptor |
| struct | CliCommandExternalConfig |
| Configuration for locating external commands. More... | |
Macros | |
| #define | CLI_PLUGIN_API_VERSION 1 |
| #define | CLI_COMMAND_INTERFACE(name, execute_callback, flags, stack_depth, app_id) |
Typedefs | |
| typedef void(* | CliCommandExecuteCallback) (PipeSide *pipe, FuriString *args, void *context) |
| CLI command execution callback pointer. | |
Enumerations | |
| enum | CliCommandFlag { CliCommandFlagDefault = 0 , CliCommandFlagParallelSafe = (1 << 0) , CliCommandFlagInsomniaSafe = (1 << 1) , CliCommandFlagDontAttachStdio = (1 << 2) , CliCommandFlagUseShellThread , CliCommandFlagExternal = (1 << 4) } |
Functions | |
| bool | cli_is_pipe_broken_or_is_etx_next_char (PipeSide *side) |
| Detects if Ctrl+C has been pressed or session has been terminated. | |
| void | cli_print_usage (const char *cmd, const char *usage, const char *arg) |
| Print unified cmd usage tip. | |
| bool | cli_sleep (PipeSide *side, uint32_t duration_in_ms) |
| Pause for a specified duration or until Ctrl+C is pressed or the session is terminated. | |
Command metadata and helpers.
| #define CLI_COMMAND_INTERFACE | ( | name, | |
| execute_callback, | |||
| flags, | |||
| stack_depth, | |||
| app_id ) |
| typedef void(* CliCommandExecuteCallback) (PipeSide *pipe, FuriString *args, void *context) |
CLI command execution callback pointer.
This callback will be called from a separate thread spawned just for your command. The pipe will be installed as the thread's stdio, so you can use printf, getchar and other standard functions to communicate with the user.
| [in] | pipe | Pipe that can be used to send and receive data. If CliCommandFlagDontAttachStdio was not set, you can also use standard C functions (printf, getc, etc.) to access this pipe. |
| [in] | args | String with what was passed after the command |
| [in] | context | Whatever you provided to cli_add_command |
| enum CliCommandFlag |
| bool cli_is_pipe_broken_or_is_etx_next_char | ( | PipeSide * | side | ) |
Detects if Ctrl+C has been pressed or session has been terminated.
| [in] | side | Pointer to pipe side given to the command thread |
| void cli_print_usage | ( | const char * | cmd, |
| const char * | usage, | ||
| const char * | arg ) |
Print unified cmd usage tip.
| cmd | cmd name |
| usage | usage tip |
| arg | arg passed by user |
| bool cli_sleep | ( | PipeSide * | side, |
| uint32_t | duration_in_ms ) |
Pause for a specified duration or until Ctrl+C is pressed or the session is terminated.
| [in] | side | Pointer to pipe side given to the command thread. |
| [in] | duration_in_ms | Duration of sleep in milliseconds. |
true if the sleep completed without interruption. false if interrupted.