mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 20:49:49 +04:00
[FL-3965] Separate cli_shell into toolbox (#4175)
* cli_shell: separate into toolbox * fix: cmd flags * fix formatting * cli: increase default stack depth * cli_shell: fix loader lock logic * cli: fix command flags * fix f18 * speaker_debug: fix * cli_registry: fix docs * ufbt: rename cli target back * cli: rename app and record * cli: fix and simplify help command * cli_master_shell: fix ext commands * fix formatting * cli: rename master to main * fix formatting --------- Co-authored-by: hedger <hedger@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#include "../cli_commands.h"
|
||||
#include "../cli_main_commands.h"
|
||||
|
||||
static void execute(PipeSide* pipe, FuriString* args, void* context) {
|
||||
UNUSED(pipe);
|
||||
@@ -7,4 +7,4 @@ static void execute(PipeSide* pipe, FuriString* args, void* context) {
|
||||
puts("Hello, World!");
|
||||
}
|
||||
|
||||
CLI_COMMAND_INTERFACE(hello_world, execute, CliCommandFlagDefault, 768);
|
||||
CLI_COMMAND_INTERFACE(hello_world, execute, CliCommandFlagParallelSafe, 768, CLI_APPID);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "../cli_commands.h"
|
||||
#include "../cli_main_commands.h"
|
||||
#include <toolbox/cli/cli_ansi.h>
|
||||
#include <toolbox/version.h>
|
||||
#include <furi_hal.h>
|
||||
#include <furi_hal_info.h>
|
||||
@@ -156,4 +157,4 @@ static void execute(PipeSide* pipe, FuriString* args, void* context) {
|
||||
#undef NEOFETCH_COLOR
|
||||
}
|
||||
|
||||
CLI_COMMAND_INTERFACE(neofetch, execute, CliCommandFlagDefault, 2048);
|
||||
CLI_COMMAND_INTERFACE(neofetch, execute, CliCommandFlagParallelSafe, 2048, CLI_APPID);
|
||||
|
||||
43
applications/services/cli/commands/subshell_demo.c
Normal file
43
applications/services/cli/commands/subshell_demo.c
Normal file
@@ -0,0 +1,43 @@
|
||||
#include "../cli_main_commands.h"
|
||||
#include <toolbox/cli/cli_registry.h>
|
||||
#include <toolbox/cli/shell/cli_shell.h>
|
||||
#include <toolbox/cli/cli_ansi.h>
|
||||
|
||||
#define RAINBOW_SUBCOMMAND \
|
||||
ANSI_FG_RED "s" ANSI_FG_YELLOW "u" ANSI_FG_BLUE "b" ANSI_FG_GREEN "c" ANSI_FG_MAGENTA \
|
||||
"o" ANSI_FG_RED "m" ANSI_FG_YELLOW "m" ANSI_FG_BLUE "a" ANSI_FG_GREEN \
|
||||
"n" ANSI_FG_MAGENTA "d"
|
||||
|
||||
static void subcommand(PipeSide* pipe, FuriString* args, void* context) {
|
||||
UNUSED(pipe);
|
||||
UNUSED(args);
|
||||
UNUSED(context);
|
||||
printf("This is a ✨" RAINBOW_SUBCOMMAND ANSI_RESET "✨!");
|
||||
}
|
||||
|
||||
static void motd(void* context) {
|
||||
UNUSED(context);
|
||||
printf("\r\n");
|
||||
printf("+------------------------------------+\r\n");
|
||||
printf("| Hello world! |\r\n");
|
||||
printf("| This is the " ANSI_FG_GREEN "MOTD" ANSI_RESET " for our " ANSI_FG_BLUE
|
||||
"subshell" ANSI_RESET "! |\r\n");
|
||||
printf("+------------------------------------+\r\n");
|
||||
}
|
||||
|
||||
static void execute(PipeSide* pipe, FuriString* args, void* context) {
|
||||
UNUSED(args);
|
||||
UNUSED(context);
|
||||
CliRegistry* registry = cli_registry_alloc();
|
||||
cli_registry_add_command(registry, "subcommand", CliCommandFlagParallelSafe, subcommand, NULL);
|
||||
|
||||
CliShell* shell = cli_shell_alloc(motd, NULL, pipe, registry, NULL);
|
||||
cli_shell_set_prompt(shell, "subshell");
|
||||
cli_shell_start(shell);
|
||||
cli_shell_join(shell);
|
||||
|
||||
cli_shell_free(shell);
|
||||
cli_registry_free(registry);
|
||||
}
|
||||
|
||||
CLI_COMMAND_INTERFACE(subshell_demo, execute, CliCommandFlagParallelSafe, 2048, CLI_APPID);
|
||||
Reference in New Issue
Block a user