[FL-1357] CLI: SD Format confirmation #495

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
its your bedtime 2021-05-26 18:48:28 +03:00 committed by GitHub
parent d76283b1a0
commit 502f449904
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -530,17 +530,22 @@ void app_sd_eject_callback(void* context) {
static void cli_sd_format(Cli* cli, string_t args, void* _ctx) { static void cli_sd_format(Cli* cli, string_t args, void* _ctx) {
SdApp* sd_app = (SdApp*)_ctx; SdApp* sd_app = (SdApp*)_ctx;
printf("formatting SD card, please wait\r\n"); printf("Formatting SD card, all data will be lost. Are you sure (y/n)?\r\n");
char c = cli_getc(cli);
if(c == 'y' || c == 'Y') {
printf("Formatting, please wait...\r\n");
// format card
app_sd_format_internal(sd_app);
// format card if(sd_app->info.status != SD_OK) {
app_sd_format_internal(sd_app); printf("SD card format error: ");
printf(fs_error_get_internal_desc(sd_app->info.status));
if(sd_app->info.status != SD_OK) { printf("\r\n");
printf("SD card format error: "); } else {
printf(fs_error_get_internal_desc(sd_app->info.status)); printf("SD card was successfully formatted.\r\n");
printf("\r\n"); }
} else { } else {
printf("SD card formatted\r\n"); printf("Cancelled.\r\n");
} }
} }