| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #include <storage/storage.h>
- #include "upython.h"
- void mp_flipper_cli(Cli* cli, FuriString* args, void* ctx) {
- UNUSED(ctx);
- if(action != ActionNone) {
- printf("%s is busy!\n", TAG);
- return;
- }
- if(furi_string_empty(args)) {
- action = ActionRepl;
- mp_flipper_repl_execute(cli);
- action = ActionNone;
- } else {
- furi_string_set(file_path, args);
- action = ActionExec;
- }
- }
- void mp_flipper_cli_register(void* args) {
- if(args != NULL) {
- file_path = furi_string_alloc_set_str(args);
- action = ActionExec;
- return;
- } else {
- file_path = furi_string_alloc_set_str(APP_ASSETS_PATH("upython"));
- action = ActionNone;
- }
- Cli* cli = furi_record_open(RECORD_CLI);
- cli_add_command(cli, CLI, CliCommandFlagParallelSafe, mp_flipper_cli, NULL);
- furi_record_close(RECORD_CLI);
- }
- void mp_flipper_cli_unregister(void* args) {
- furi_string_free(file_path);
- if(args != NULL) {
- return;
- }
- Cli* cli = furi_record_open(RECORD_CLI);
- cli_delete_command(cli, CLI);
- furi_record_close(RECORD_CLI);
- }
|