All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
cli_command.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <furi.h>
9#include <toolbox/pipe.h>
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16#define CLI_PLUGIN_API_VERSION 1
17
18typedef enum {
24 (1
25 << 3),
27 // internal flags (do not set them yourselves!)
28
31
47typedef void (*CliCommandExecuteCallback)(PipeSide* pipe, FuriString* args, void* context);
48
49typedef struct {
50 char* name;
51 CliCommandExecuteCallback execute_callback;
52 CliCommandFlag flags;
53 size_t stack_depth;
55
59typedef struct {
60 const char* search_directory; //<! The directory to look in
61 const char* fal_prefix; //<! File name prefix that commands should have
62 const char* appid; //<! Expected plugin-reported appid
64
74
81void cli_print_usage(const char* cmd, const char* usage, const char* arg);
82
83#define CLI_COMMAND_INTERFACE(name, execute_callback, flags, stack_depth, app_id) \
84 static const CliCommandDescriptor cli_##name##_desc = { \
85 #name, \
86 &execute_callback, \
87 flags, \
88 stack_depth, \
89 }; \
90 \
91 static const FlipperAppPluginDescriptor plugin_descriptor = { \
92 .appid = app_id, \
93 .ep_api_version = CLI_PLUGIN_API_VERSION, \
94 .entry_point = &cli_##name##_desc, \
95 }; \
96 \
97 const FlipperAppPluginDescriptor* cli_##name##_ep(void) { \
98 return &plugin_descriptor; \
99 }
100
101#ifdef __cplusplus
102}
103#endif
void cli_print_usage(const char *cmd, const char *usage, const char *arg)
Print unified cmd usage tip.
Definition cli_command.c:11
CliCommandFlag
Definition cli_command.h:18
@ CliCommandFlagDefault
Default.
Definition cli_command.h:19
@ CliCommandFlagInsomniaSafe
Safe to run with insomnia mode on.
Definition cli_command.h:21
@ CliCommandFlagUseShellThread
Don't start a separate thread to run the command in.
Definition cli_command.h:23
@ CliCommandFlagDontAttachStdio
Do no attach I/O pipe to thread stdio.
Definition cli_command.h:22
@ CliCommandFlagExternal
The command comes from a .fal file.
Definition cli_command.h:29
@ CliCommandFlagParallelSafe
Safe to run in parallel with other apps.
Definition cli_command.h:20
void(* CliCommandExecuteCallback)(PipeSide *pipe, FuriString *args, void *context)
CLI command execution callback pointer.
Definition cli_command.h:47
bool cli_is_pipe_broken_or_is_etx_next_char(PipeSide *side)
Detects if Ctrl+C has been pressed or session has been terminated.
Definition cli_command.c:4
Flipper application.
Pipe convenience module.
Definition cli_command.h:49
Configuration for locating external commands.
Definition cli_command.h:59
Definition string.c:4
There are two PipeSides per pipe.
Definition pipe.c:17