Skip to content

Commit

Permalink
clang format
Browse files Browse the repository at this point in the history
  • Loading branch information
akopachov committed Aug 25, 2023
1 parent 0d9c3b2 commit 4f6d25c
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 23 deletions.
23 changes: 16 additions & 7 deletions cli/commands/details/details.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@

typedef void (*TOTP_CLI_DETAILS_HEADER_FORMATTER)();
typedef void (*TOTP_CLI_DETAILS_FOOTER_FORMATTER)();
typedef void (*TOTP_CLI_DETAILS_AUTOMATION_FEATURE_ITEM_FORMATTER)(const char* key, const char* feature, bool* header_printed);
typedef void (*TOTP_CLI_DETAILS_AUTOMATION_FEATURE_ITEM_FORMATTER)(
const char* key,
const char* feature,
bool* header_printed);
typedef void (*TOTP_CLI_DETAILS_CSTR_FORMATTER)(const char* key, const char* value);
typedef void (*TOTP_CLI_DETAILS_UINT8T_FORMATTER)(const char* key, uint8_t value);
typedef void (*TOTP_CLI_DETAILS_SIZET_FORMATTER)(const char* key, size_t value);
Expand Down Expand Up @@ -42,24 +45,30 @@ static const TotpCliDetailsFormatter available_formatters[] = {
.sizet_formatter = &details_output_formatter_print_sizet_tsv},
};

static void print_automation_features(const TokenInfo* token_info, const TotpCliDetailsFormatter* formatter) {
static void print_automation_features(
const TokenInfo* token_info,
const TotpCliDetailsFormatter* formatter) {
bool header_printed = false;
const char* AUTOMATION_FEATURES_PRINT_KEY = "Automation features";
if(token_info->automation_features == TokenAutomationFeatureNone) {
(*formatter->automation_feature_item_formatter)(AUTOMATION_FEATURES_PRINT_KEY, "None", &header_printed);
(*formatter->automation_feature_item_formatter)(
AUTOMATION_FEATURES_PRINT_KEY, "None", &header_printed);
return;
}

if(token_info->automation_features & TokenAutomationFeatureEnterAtTheEnd) {
(*formatter->automation_feature_item_formatter)(AUTOMATION_FEATURES_PRINT_KEY, "Type <Enter> key at the end", &header_printed);
(*formatter->automation_feature_item_formatter)(
AUTOMATION_FEATURES_PRINT_KEY, "Type <Enter> key at the end", &header_printed);
}

if(token_info->automation_features & TokenAutomationFeatureTabAtTheEnd) {
(*formatter->automation_feature_item_formatter)(AUTOMATION_FEATURES_PRINT_KEY, "Type <Tab> key at the end", &header_printed);
(*formatter->automation_feature_item_formatter)(
AUTOMATION_FEATURES_PRINT_KEY, "Type <Tab> key at the end", &header_printed);
}

if(token_info->automation_features & TokenAutomationFeatureTypeSlower) {
(*formatter->automation_feature_item_formatter)(AUTOMATION_FEATURES_PRINT_KEY, "Type slower", &header_printed);
(*formatter->automation_feature_item_formatter)(
AUTOMATION_FEATURES_PRINT_KEY, "Type slower", &header_printed);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ void details_output_formatter_print_footer_table() {
TOTP_CLI_PRINTF("+----------------------+------------------------------+\r\n");
}

void details_output_formatter_print_automation_feature_table(const char* key, const char* feature, bool* header_printed) {
TOTP_CLI_PRINTF(
"| %-20s | %-28.28s |\r\n",
*header_printed ? "" : key,
feature);
*header_printed = true;
void details_output_formatter_print_automation_feature_table(
const char* key,
const char* feature,
bool* header_printed) {
TOTP_CLI_PRINTF("| %-20s | %-28.28s |\r\n", *header_printed ? "" : key, feature);
*header_printed = true;
}

void details_output_formatter_print_cstr_table(const char* key, const char* value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

void details_output_formatter_print_header_table();
void details_output_formatter_print_footer_table();
void details_output_formatter_print_automation_feature_table(const char* key, const char* feature, bool* header_printed);
void details_output_formatter_print_automation_feature_table(
const char* key,
const char* feature,
bool* header_printed);
void details_output_formatter_print_cstr_table(const char* key, const char* value);
void details_output_formatter_print_uint8t_table(const char* key, uint8_t value);
void details_output_formatter_print_sizet_table(const char* key, size_t value);
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ void details_output_formatter_print_header_tsv() {
void details_output_formatter_print_footer_tsv() {
}

void details_output_formatter_print_automation_feature_tsv(const char* key, const char* feature, bool* header_printed) {
TOTP_CLI_PRINTF(
"%s\t%s\r\n",
*header_printed ? "" : key,
feature);
*header_printed = true;
void details_output_formatter_print_automation_feature_tsv(
const char* key,
const char* feature,
bool* header_printed) {
TOTP_CLI_PRINTF("%s\t%s\r\n", *header_printed ? "" : key, feature);
*header_printed = true;
}

void details_output_formatter_print_cstr_tsv(const char* key, const char* value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

void details_output_formatter_print_header_tsv();
void details_output_formatter_print_footer_tsv();
void details_output_formatter_print_automation_feature_tsv(const char* key, const char* feature, bool* header_printed);
void details_output_formatter_print_automation_feature_tsv(
const char* key,
const char* feature,
bool* header_printed);
void details_output_formatter_print_cstr_tsv(const char* key, const char* value);
void details_output_formatter_print_uint8t_tsv(const char* key, uint8_t value);
void details_output_formatter_print_sizet_tsv(const char* key, size_t value);
3 changes: 1 addition & 2 deletions cli/commands/list/list.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ static const TotpCliListFormatter available_formatters[] = {

{.header_formatter = &list_output_formatter_print_header_tsv,
.body_item_formatter = &list_output_formatter_print_body_item_tsv,
.footer_formatter = &list_output_formatter_print_footer_tsv}
};
.footer_formatter = &list_output_formatter_print_footer_tsv}};

#ifdef TOTP_CLI_RICH_HELP_ENABLED
void totp_cli_command_list_docopt_commands() {
Expand Down

0 comments on commit 4f6d25c

Please sign in to comment.