From 8d7167c7db81e26f9ffb76681350a6eded2237db Mon Sep 17 00:00:00 2001 From: "alex.kopachov" Date: Wed, 26 Oct 2022 11:09:02 +0200 Subject: [PATCH] Ran clang format --- services/cli/cli.c | 22 ++++++++++------- services/cli/cli_helpers.h | 4 +++- services/cli/commands/add/add.c | 29 ++++++++++++++++------- services/cli/commands/delete/delete.c | 12 ++++++---- services/cli/commands/help/help.c | 7 ++++-- services/cli/commands/list/list.c | 6 +++-- services/cli/commands/timezone/timezone.c | 14 +++++++---- 7 files changed, 63 insertions(+), 31 deletions(-) diff --git a/services/cli/cli.c b/services/cli/cli.c index 764e0ac9d5d..3a7afdd96e3 100644 --- a/services/cli/cli.c +++ b/services/cli/cli.c @@ -11,7 +11,8 @@ static void totp_cli_print_unknown_command(FuriString* unknown_command) { TOTP_CLI_PRINTF( - "Command \"%s\" is unknown. Use \"" TOTP_CLI_COMMAND_HELP "\" command to get list of available commands.", + "Command \"%s\" is unknown. Use \"" TOTP_CLI_COMMAND_HELP + "\" command to get list of available commands.", furi_string_get_cstr(unknown_command)); } @@ -22,22 +23,25 @@ static void totp_cli_handler(Cli* cli, FuriString* args, void* context) { args_read_string_and_trim(args, cmd); - if(furi_string_cmp_str(cmd, TOTP_CLI_COMMAND_HELP) == 0 || - furi_string_cmp_str(cmd, TOTP_CLI_COMMAND_HELP_ALT) == 0 || - furi_string_cmp_str(cmd, TOTP_CLI_COMMAND_HELP_ALT2) == 0 || - furi_string_empty(cmd)) { + if(furi_string_cmp_str(cmd, TOTP_CLI_COMMAND_HELP) == 0 || + furi_string_cmp_str(cmd, TOTP_CLI_COMMAND_HELP_ALT) == 0 || + furi_string_cmp_str(cmd, TOTP_CLI_COMMAND_HELP_ALT2) == 0 || furi_string_empty(cmd)) { totp_cli_command_help_handle(); - } else if(furi_string_cmp_str(cmd, TOTP_CLI_COMMAND_ADD) == 0 || + } else if( + furi_string_cmp_str(cmd, TOTP_CLI_COMMAND_ADD) == 0 || furi_string_cmp_str(cmd, TOTP_CLI_COMMAND_ADD_ALT) == 0 || furi_string_cmp_str(cmd, TOTP_CLI_COMMAND_ADD_ALT2) == 0) { totp_cli_command_add_handle(plugin_state, args, cli); - } else if(furi_string_cmp_str(cmd, TOTP_CLI_COMMAND_LIST) == 0 || + } else if( + furi_string_cmp_str(cmd, TOTP_CLI_COMMAND_LIST) == 0 || furi_string_cmp_str(cmd, TOTP_CLI_COMMAND_LIST_ALT) == 0) { totp_cli_command_list_handle(plugin_state, cli); - } else if(furi_string_cmp_str(cmd, TOTP_CLI_COMMAND_DELETE) == 0 || + } else if( + furi_string_cmp_str(cmd, TOTP_CLI_COMMAND_DELETE) == 0 || furi_string_cmp_str(cmd, TOTP_CLI_COMMAND_DELETE_ALT) == 0) { totp_cli_command_delete_handle(plugin_state, args, cli); - } else if(furi_string_cmp_str(cmd, TOTP_CLI_COMMAND_TIMEZONE) == 0 || + } else if( + furi_string_cmp_str(cmd, TOTP_CLI_COMMAND_TIMEZONE) == 0 || furi_string_cmp_str(cmd, TOTP_CLI_COMMAND_TIMEZONE_ALT) == 0) { totp_cli_command_timezone_handle(plugin_state, args, cli); } else { diff --git a/services/cli/cli_helpers.h b/services/cli/cli_helpers.h index 916ccbc8b84..216925e5096 100644 --- a/services/cli/cli_helpers.h +++ b/services/cli/cli_helpers.h @@ -21,6 +21,8 @@ #define TOTP_CLI_DELETE_LAST_LINE() TOTP_CLI_PRINTF("\033[A\33[2K\r") #define TOTP_CLI_DELETE_CURRENT_LINE() TOTP_CLI_PRINTF("\33[2K\r") -#define TOTP_CLI_PRINT_INVALID_ARGUMENTS() TOTP_CLI_PRINTF("Invalid command arguments. use \"help\" command to get list of available commands") +#define TOTP_CLI_PRINT_INVALID_ARGUMENTS() \ + TOTP_CLI_PRINTF( \ + "Invalid command arguments. use \"help\" command to get list of available commands") bool totp_cli_ensure_authenticated(PluginState* plugin_state, Cli* cli); diff --git a/services/cli/commands/add/add.c b/services/cli/commands/add/add.c index 45a63a2a9ee..41ff5b86077 100644 --- a/services/cli/commands/add/add.c +++ b/services/cli/commands/add/add.c @@ -47,14 +47,18 @@ static bool token_info_set_algo_from_str(TokenInfo* token_info, FuriString* str) } void totp_cli_command_add_docopt_commands() { - TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_ADD ", " TOTP_CLI_COMMAND_ADD_ALT ", " TOTP_CLI_COMMAND_ADD_ALT2 " Add new token\r\n"); + TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_ADD ", " TOTP_CLI_COMMAND_ADD_ALT + ", " TOTP_CLI_COMMAND_ADD_ALT2 " Add new token\r\n"); } void totp_cli_command_add_docopt_usage() { - TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_NAME " " DOCOPT_REQUIRED(TOTP_CLI_COMMAND_ADD " | " TOTP_CLI_COMMAND_ADD_ALT " | " TOTP_CLI_COMMAND_ADD_ALT2) " " DOCOPT_ARGUMENT(TOTP_CLI_COMMAND_ADD_ARG_NAME) " " - DOCOPT_OPTIONAL(DOCOPT_OPTION(TOTP_CLI_COMMAND_ADD_ARG_ALGO_PREFIX, DOCOPT_ARGUMENT(TOTP_CLI_COMMAND_ADD_ARG_ALGO))) " " - DOCOPT_OPTIONAL(DOCOPT_OPTION(TOTP_CLI_COMMAND_ADD_ARG_DIGITS_PREFIX, DOCOPT_ARGUMENT(TOTP_CLI_COMMAND_ADD_ARG_DIGITS))) " " - DOCOPT_OPTIONAL(DOCOPT_SWITCH(TOTP_CLI_COMMAND_ADD_ARG_UNSECURE_PREFIX))"\r\n"); + TOTP_CLI_PRINTF( + " " TOTP_CLI_COMMAND_NAME + " " DOCOPT_REQUIRED(TOTP_CLI_COMMAND_ADD " | " TOTP_CLI_COMMAND_ADD_ALT " | " TOTP_CLI_COMMAND_ADD_ALT2) " " DOCOPT_ARGUMENT(TOTP_CLI_COMMAND_ADD_ARG_NAME) " " DOCOPT_OPTIONAL( + DOCOPT_OPTION( + TOTP_CLI_COMMAND_ADD_ARG_ALGO_PREFIX, + DOCOPT_ARGUMENT( + TOTP_CLI_COMMAND_ADD_ARG_ALGO))) " " DOCOPT_OPTIONAL(DOCOPT_OPTION(TOTP_CLI_COMMAND_ADD_ARG_DIGITS_PREFIX, DOCOPT_ARGUMENT(TOTP_CLI_COMMAND_ADD_ARG_DIGITS))) " " DOCOPT_OPTIONAL(DOCOPT_SWITCH(TOTP_CLI_COMMAND_ADD_ARG_UNSECURE_PREFIX)) "\r\n"); } void totp_cli_command_add_docopt_arguments() { @@ -62,10 +66,17 @@ void totp_cli_command_add_docopt_arguments() { } void totp_cli_command_add_docopt_options() { - TOTP_CLI_PRINTF(" " DOCOPT_OPTION(TOTP_CLI_COMMAND_ADD_ARG_ALGO_PREFIX, DOCOPT_ARGUMENT(TOTP_CLI_COMMAND_ADD_ARG_ALGO)) " Token hashing algorithm.\r\n"); - TOTP_CLI_PRINTF(" Could be one of: sha1, sha256, sha512 " DOCOPT_DEFAULT("sha1") "\r\n"); - TOTP_CLI_PRINTF(" " DOCOPT_OPTION(TOTP_CLI_COMMAND_ADD_ARG_DIGITS_PREFIX, DOCOPT_ARGUMENT(TOTP_CLI_COMMAND_ADD_ARG_DIGITS))" Number of digits to generate, one of: 6, 8 " DOCOPT_DEFAULT("6") "\r\n"); - TOTP_CLI_PRINTF(" " DOCOPT_SWITCH(TOTP_CLI_COMMAND_ADD_ARG_UNSECURE_PREFIX) " Show console user input as-is without masking\r\n"); + TOTP_CLI_PRINTF(" " DOCOPT_OPTION( + TOTP_CLI_COMMAND_ADD_ARG_ALGO_PREFIX, + DOCOPT_ARGUMENT(TOTP_CLI_COMMAND_ADD_ARG_ALGO)) " Token hashing algorithm.\r\n"); + TOTP_CLI_PRINTF( + " Could be one of: sha1, sha256, sha512 " DOCOPT_DEFAULT("sha1") "\r\n"); + TOTP_CLI_PRINTF(" " DOCOPT_OPTION( + TOTP_CLI_COMMAND_ADD_ARG_DIGITS_PREFIX, + DOCOPT_ARGUMENT( + TOTP_CLI_COMMAND_ADD_ARG_DIGITS)) " Number of digits to generate, one of: 6, 8 " DOCOPT_DEFAULT("6") "\r\n"); + TOTP_CLI_PRINTF(" " DOCOPT_SWITCH( + TOTP_CLI_COMMAND_ADD_ARG_UNSECURE_PREFIX) " Show console user input as-is without masking\r\n"); } void totp_cli_command_add_handle(PluginState* plugin_state, FuriString* args, Cli* cli) { diff --git a/services/cli/commands/delete/delete.c b/services/cli/commands/delete/delete.c index 9034f812d71..bbeb6ec4d05 100644 --- a/services/cli/commands/delete/delete.c +++ b/services/cli/commands/delete/delete.c @@ -12,12 +12,15 @@ #define TOTP_CLI_COMMAND_DELETE_ARG_FORCE_SUFFIX "-f" void totp_cli_command_delete_docopt_commands() { - TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_DELETE ", " TOTP_CLI_COMMAND_DELETE_ALT " Delete existing token\r\n"); + TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_DELETE ", " TOTP_CLI_COMMAND_DELETE_ALT + " Delete existing token\r\n"); } void totp_cli_command_delete_docopt_usage() { - TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_NAME " " DOCOPT_REQUIRED(TOTP_CLI_COMMAND_DELETE " | " TOTP_CLI_COMMAND_DELETE_ALT) " " DOCOPT_ARGUMENT(TOTP_CLI_COMMAND_DELETE_ARG_INDEX) " " - DOCOPT_OPTIONAL(DOCOPT_SWITCH(TOTP_CLI_COMMAND_DELETE_ARG_FORCE_SUFFIX)) "\r\n"); + TOTP_CLI_PRINTF( + " " TOTP_CLI_COMMAND_NAME + " " DOCOPT_REQUIRED(TOTP_CLI_COMMAND_DELETE " | " TOTP_CLI_COMMAND_DELETE_ALT) " " DOCOPT_ARGUMENT( + TOTP_CLI_COMMAND_DELETE_ARG_INDEX) " " DOCOPT_OPTIONAL(DOCOPT_SWITCH(TOTP_CLI_COMMAND_DELETE_ARG_FORCE_SUFFIX)) "\r\n"); } void totp_cli_command_delete_docopt_arguments() { @@ -25,7 +28,8 @@ void totp_cli_command_delete_docopt_arguments() { } void totp_cli_command_delete_docopt_options() { - TOTP_CLI_PRINTF(" " DOCOPT_SWITCH(TOTP_CLI_COMMAND_DELETE_ARG_FORCE_SUFFIX) " Force command to do not ask user for interactive confirmation\r\n"); + TOTP_CLI_PRINTF(" " DOCOPT_SWITCH( + TOTP_CLI_COMMAND_DELETE_ARG_FORCE_SUFFIX) " Force command to do not ask user for interactive confirmation\r\n"); } void totp_cli_command_delete_handle(PluginState* plugin_state, FuriString* args, Cli* cli) { diff --git a/services/cli/commands/help/help.c b/services/cli/commands/help/help.c index 6392344503a..ab592fbba2b 100644 --- a/services/cli/commands/help/help.c +++ b/services/cli/commands/help/help.c @@ -6,11 +6,14 @@ #include "../timezone/timezone.h" void totp_cli_command_help_docopt_commands() { - TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_HELP ", " TOTP_CLI_COMMAND_HELP_ALT ", " TOTP_CLI_COMMAND_HELP_ALT2 " Show command usage help\r\n"); + TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_HELP ", " TOTP_CLI_COMMAND_HELP_ALT + ", " TOTP_CLI_COMMAND_HELP_ALT2 " Show command usage help\r\n"); } void totp_cli_command_help_docopt_usage() { - TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_NAME " " DOCOPT_REQUIRED(TOTP_CLI_COMMAND_HELP " | " TOTP_CLI_COMMAND_HELP_ALT " | " TOTP_CLI_COMMAND_HELP_ALT2) "\r\n"); + TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_NAME " " DOCOPT_REQUIRED( + TOTP_CLI_COMMAND_HELP " | " TOTP_CLI_COMMAND_HELP_ALT + " | " TOTP_CLI_COMMAND_HELP_ALT2) "\r\n"); } void totp_cli_command_help_handle() { diff --git a/services/cli/commands/list/list.c b/services/cli/commands/list/list.c index e269904e15c..61791084d96 100644 --- a/services/cli/commands/list/list.c +++ b/services/cli/commands/list/list.c @@ -30,11 +30,13 @@ static uint8_t get_digits_as_int(TokenDigitsCount digits) { } void totp_cli_command_list_docopt_commands() { - TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_LIST ", " TOTP_CLI_COMMAND_LIST_ALT " List all available tokens\r\n"); + TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_LIST ", " TOTP_CLI_COMMAND_LIST_ALT + " List all available tokens\r\n"); } void totp_cli_command_list_docopt_usage() { - TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_NAME " " DOCOPT_REQUIRED(TOTP_CLI_COMMAND_LIST " | " TOTP_CLI_COMMAND_LIST_ALT) "\r\n"); + TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_NAME " " DOCOPT_REQUIRED( + TOTP_CLI_COMMAND_LIST " | " TOTP_CLI_COMMAND_LIST_ALT) "\r\n"); } void totp_cli_command_list_handle(PluginState* plugin_state, Cli* cli) { diff --git a/services/cli/commands/timezone/timezone.c b/services/cli/commands/timezone/timezone.c index 69eebcdbae3..d997aa116f8 100644 --- a/services/cli/commands/timezone/timezone.c +++ b/services/cli/commands/timezone/timezone.c @@ -7,16 +7,22 @@ #define TOTP_CLI_COMMAND_TIMEZONE_ARG_TIMEZONE "timezone" void totp_cli_command_timezone_docopt_commands() { - TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_TIMEZONE ", " TOTP_CLI_COMMAND_TIMEZONE_ALT " Get or set current timezone\r\n"); + TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_TIMEZONE ", " TOTP_CLI_COMMAND_TIMEZONE_ALT + " Get or set current timezone\r\n"); } void totp_cli_command_timezone_docopt_usage() { - TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_NAME " " DOCOPT_REQUIRED(TOTP_CLI_COMMAND_TIMEZONE " | " TOTP_CLI_COMMAND_TIMEZONE_ALT) " " DOCOPT_OPTIONAL(DOCOPT_ARGUMENT(TOTP_CLI_COMMAND_TIMEZONE_ARG_TIMEZONE)) "\r\n"); + TOTP_CLI_PRINTF( + " " TOTP_CLI_COMMAND_NAME + " " DOCOPT_REQUIRED(TOTP_CLI_COMMAND_TIMEZONE " | " TOTP_CLI_COMMAND_TIMEZONE_ALT) " " DOCOPT_OPTIONAL( + DOCOPT_ARGUMENT(TOTP_CLI_COMMAND_TIMEZONE_ARG_TIMEZONE)) "\r\n"); } void totp_cli_command_timezone_docopt_arguments() { - TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_TIMEZONE_ARG_TIMEZONE " Timezone offset in hours to be set.\r\n"); - TOTP_CLI_PRINTF(" If not provided then current timezone offset will be printed\r\n"); + TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_TIMEZONE_ARG_TIMEZONE + " Timezone offset in hours to be set.\r\n"); + TOTP_CLI_PRINTF( + " If not provided then current timezone offset will be printed\r\n"); } void totp_cli_command_timezone_handle(PluginState* plugin_state, FuriString* args, Cli* cli) {