[FL-1138] CLI commands unification (#484)
* power_otg command, merge sd_info and sd_status, added small usage instructions for commands with args * remove duplicated sd status string * cli_print_usage added, typo fix
This commit is contained in:
		| @@ -70,8 +70,41 @@ void cli_print_version(const Version* version) { | ||||
|     } | ||||
| } | ||||
|  | ||||
| void cli_print_usage(const char* cmd, const char* usage, const char* arg) { | ||||
|     furi_assert(cmd); | ||||
|     furi_assert(arg); | ||||
|     furi_assert(usage); | ||||
|  | ||||
|     printf("%s: illegal option -- %s\r\nusage: %s %s", cmd, arg, cmd, usage); | ||||
| } | ||||
|  | ||||
| void cli_motd() { | ||||
|     printf("Flipper cli.\r\n"); | ||||
|     printf("                                      __ \r\n \ | ||||
|                                  _.-~  ) \r\n \ | ||||
|                       _..--~~~~,'   ,-/     _\r\n \ | ||||
|                    .-'. . . .'   ,-','    ,' ) \r\n \ | ||||
|                  ,'. . . _   ,--~,-'__..-'  ,' \r\n \ | ||||
|                ,'. . .  (@)' ---~~~~      ,'\r\n \ | ||||
|               /. . . . '~~             ,-'\r\n \ | ||||
|              /. . . . .             ,-'\r\n \ | ||||
|             ; . . . .  - .        ,'\r\n \ | ||||
|            : . . . .       _     /\r\n \ | ||||
|           . . . . .          `-.:\r\n \ | ||||
|          . . . ./  - .          )\r\n \ | ||||
|        .  . . |  _____..---.._/ _____\r\n \ | ||||
| ~-----~~~~----~~~~                   ~~~-----~~~~~-----~\r\n \ | ||||
|  ______ _ _                          _____ _      _____\r\n \ | ||||
| |  ____| (_)                        / ____| |    |_   _|\r\n \ | ||||
| | |__  | |_ _ __  _ __   ___ _ __  | |    | |      | |\r\n \ | ||||
| |  __| | | | '_ \\| '_ \\ / _ \\ '__| | |    | |      | |\r\n \ | ||||
| | |    | | | |_) | |_) |  __/ |    | |____| |____ _| |_\r\n \ | ||||
| |_|    |_|_| .__/| .__/ \\___|_|     \\_____|______|_____|\r\n \ | ||||
|            | |   | |\r\n \ | ||||
|            |_|   |_|\r\n\r\n" | ||||
|  | ||||
|     ); | ||||
|  | ||||
|     printf("You are now connected to Flipper Command Line Interface.\r\n\r\n"); | ||||
|  | ||||
|     printf("Bootloader\r\n"); | ||||
|     cli_print_version(api_hal_version_get_boot_version()); | ||||
|   | ||||
| @@ -27,6 +27,14 @@ typedef void (*CliCallback)(Cli* cli, string_t args, void* context); | ||||
|  */ | ||||
| void cli_add_command(Cli* cli, const char* name, CliCallback callback, void* context); | ||||
|  | ||||
| /* Print unified cmd usage tip | ||||
|  * @param cmd - cmd name | ||||
|  * @param usage - usage tip | ||||
|  * @param arg - arg passed by user | ||||
|  */ | ||||
|  | ||||
| void cli_print_usage(const char* cmd, const char* usage, const char* arg); | ||||
|  | ||||
| /* Delete cli command | ||||
|  * @param cli - pointer to cli instance | ||||
|  * @param name - command name | ||||
|   | ||||
| @@ -115,7 +115,7 @@ void cli_command_vibro(Cli* cli, string_t args, void* context) { | ||||
|         notification_message_block(notification, &sequence_set_vibro_on); | ||||
|         furi_record_close("notification"); | ||||
|     } else { | ||||
|         printf("Wrong input"); | ||||
|         cli_print_usage("vibro", "<1|0>", string_get_cstr(args)); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @@ -126,7 +126,7 @@ void cli_command_led(Cli* cli, string_t args, void* context) { | ||||
|     string_init(light_name); | ||||
|     size_t ws = string_search_char(args, ' '); | ||||
|     if(ws == STRING_FAILURE) { | ||||
|         printf("Wrong input"); | ||||
|         cli_print_usage("led", "<r|g|b|bl> <0-255>", string_get_cstr(args)); | ||||
|         string_clear(light_name); | ||||
|         return; | ||||
|     } else { | ||||
| @@ -144,7 +144,7 @@ void cli_command_led(Cli* cli, string_t args, void* context) { | ||||
|     } else if(!string_cmp(light_name, "bl")) { | ||||
|         notification_led_message.type = NotificationMessageTypeLedDisplay; | ||||
|     } else { | ||||
|         printf("Wrong argument"); | ||||
|         cli_print_usage("led", "<r|g|b|bl> <0-255>", string_get_cstr(args)); | ||||
|         string_clear(light_name); | ||||
|         return; | ||||
|     } | ||||
| @@ -153,7 +153,7 @@ void cli_command_led(Cli* cli, string_t args, void* context) { | ||||
|     char* end_ptr; | ||||
|     uint32_t value = strtoul(string_get_cstr(args), &end_ptr, 0); | ||||
|     if(!(value < 256 && *end_ptr == '\0')) { | ||||
|         printf("Wrong argument"); | ||||
|         cli_print_usage("led", "<r|g|b|bl> <0-255>", string_get_cstr(args)); | ||||
|         return; | ||||
|     } | ||||
|  | ||||
| @@ -191,7 +191,7 @@ void cli_command_gpio_set(Cli* cli, string_t args, void* context) { | ||||
|     string_init(pin_name); | ||||
|     size_t ws = string_search_char(args, ' '); | ||||
|     if(ws == STRING_FAILURE) { | ||||
|         printf("Wrong input. Correct usage: gpio_set <pin_name> <0|1>"); | ||||
|         cli_print_usage("gpio_set", "<pin_name> <0|1>", string_get_cstr(args)); | ||||
|         string_clear(pin_name); | ||||
|         return; | ||||
|     } else { | ||||
|   | ||||
| @@ -2,4 +2,4 @@ | ||||
|  | ||||
| #include "cli_i.h" | ||||
|  | ||||
| void cli_commands_init(Cli* cli); | ||||
| void cli_commands_init(Cli* cli); | ||||
		Reference in New Issue
	
	Block a user