diff --git a/cmd/command.c b/cmd/command.c index f22b22d..3269835 100644 --- a/cmd/command.c +++ b/cmd/command.c @@ -9,7 +9,7 @@ #include #include -#define OUTPUT_STREAM b_stderr +#define OUTPUT_STREAM b_stdtty_err static struct b_btree command_list = {0}; @@ -415,7 +415,8 @@ static void get_usage_string( b_string_append_cstr(out, " "); - if (opt->opt == (struct b_command_option *)(uintptr_t)B_COMMAND_INVALID_ID) { + if (opt->opt + == (struct b_command_option *)(uintptr_t)B_COMMAND_INVALID_ID) { b_string_append_cstr(out, "[OPTIONS]"); } else { z__b_get_option_usage_string( @@ -433,7 +434,8 @@ static void get_usage_string( b_string_append_cstr(out, " "); - if (arg->arg == (struct b_command_arg *)(uintptr_t)B_COMMAND_INVALID_ID) { + if (arg->arg + == (struct b_command_arg *)(uintptr_t)B_COMMAND_INVALID_ID) { b_string_append_cstr(out, "[ARGS]"); } else { z__b_get_arg_usage_string(arg->arg, false, out); @@ -545,8 +547,10 @@ static void print_options_list(struct b_command *cmd) z__b_get_option_usage_string(opt, CMD_STR_COLOUR, opt_str); z__b_get_option_description(opt, desc_str); - size_t opt_len - = b_string_get_size(opt_str, B_STRLEN_IGNORE_ESC | B_STRLEN_IGNORE_MOD) + 4; + size_t opt_len = b_string_get_size( + opt_str, B_STRLEN_IGNORE_ESC + | B_STRLEN_IGNORE_MOD) + + 4; size_t desc_len = b_string_get_size( desc_str, B_STRLEN_IGNORE_ESC | B_STRLEN_IGNORE_MOD); @@ -566,7 +570,8 @@ static void print_options_list(struct b_command *cmd) size_t i = 0; b_queue_foreach (&it, &cmd->b_opt) { - struct b_command_option *opt = b_unbox(struct b_command_option, it.entry, opt_entry); + struct b_command_option *opt + = b_unbox(struct b_command_option, it.entry, opt_entry); if (!opt) { continue; } @@ -576,8 +581,12 @@ static void print_options_list(struct b_command *cmd) z__b_get_option_usage_string(opt, CMD_STR_COLOUR, opt_str); z__b_get_option_description(opt, desc_str); - size_t opt_len = b_string_get_size(opt_str, B_STRLEN_IGNORE_ESC | B_STRLEN_IGNORE_MOD) + 4; - size_t desc_len = b_string_get_size(desc_str, B_STRLEN_IGNORE_ESC | B_STRLEN_IGNORE_MOD); + size_t opt_len = b_string_get_size( + opt_str, B_STRLEN_IGNORE_ESC + | B_STRLEN_IGNORE_MOD) + + 4; + size_t desc_len = b_string_get_size( + desc_str, B_STRLEN_IGNORE_ESC | B_STRLEN_IGNORE_MOD); bool new_paragraph = description_on_separate_line(opt_len, desc_len); @@ -655,7 +664,10 @@ static void print_args_list(struct b_command *cmd) b_tty_puts(OUTPUT_STREAM, 0, " "); b_tty_puts(OUTPUT_STREAM, 0, b_string_ptr(str)); - unsigned int len = b_string_get_size(str, B_STRLEN_IGNORE_ESC | B_STRLEN_IGNORE_MOD) + 4; + unsigned int len + = b_string_get_size( + str, B_STRLEN_IGNORE_ESC | B_STRLEN_IGNORE_MOD) + + 4; while (len < format.p_left_margin) { b_tty_putc(OUTPUT_STREAM, 0, ' '); len++; @@ -684,7 +696,9 @@ static void print_commands_list(struct b_command *cmd) b_string_clear(str); get_command_string(sub, str); - size_t len = b_string_get_size( str, B_STRLEN_IGNORE_ESC | B_STRLEN_IGNORE_MOD) + 4; + size_t len = b_string_get_size( + str, B_STRLEN_IGNORE_ESC | B_STRLEN_IGNORE_MOD) + + 4; if (len > desb_margin) { desb_margin = len; @@ -706,7 +720,10 @@ static void print_commands_list(struct b_command *cmd) b_tty_puts(OUTPUT_STREAM, 0, " "); b_tty_puts(OUTPUT_STREAM, 0, b_string_ptr(str)); - unsigned int len = b_string_get_size(str, B_STRLEN_IGNORE_ESC | B_STRLEN_IGNORE_MOD) + 4; + unsigned int len + = b_string_get_size( + str, B_STRLEN_IGNORE_ESC | B_STRLEN_IGNORE_MOD) + + 4; while (len < format.p_left_margin) { b_tty_putc(OUTPUT_STREAM, 0, ' '); len++; @@ -852,7 +869,8 @@ static void print_help(struct b_command *cmd) b_paragraph_format format = {0}; if (!cmd->b_parent) { - b_tty_printf(OUTPUT_STREAM, 0, F_GREEN "%s" F_RESET "\n", cmd->b_name); + b_tty_printf( + OUTPUT_STREAM, 0, F_GREEN "%s" F_RESET "\n", cmd->b_name); } if (cmd->b_description) {