cmd: update references to b_stderr

This commit is contained in:
2025-06-27 21:53:03 +01:00
parent b00d9c51bd
commit 2ced9a8309

View File

@@ -9,7 +9,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#define OUTPUT_STREAM b_stderr #define OUTPUT_STREAM b_stdtty_err
static struct b_btree command_list = {0}; static struct b_btree command_list = {0};
@@ -415,7 +415,8 @@ static void get_usage_string(
b_string_append_cstr(out, " "); 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]"); b_string_append_cstr(out, "[OPTIONS]");
} else { } else {
z__b_get_option_usage_string( z__b_get_option_usage_string(
@@ -433,7 +434,8 @@ static void get_usage_string(
b_string_append_cstr(out, " "); 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]"); b_string_append_cstr(out, "[ARGS]");
} else { } else {
z__b_get_arg_usage_string(arg->arg, false, out); 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_usage_string(opt, CMD_STR_COLOUR, opt_str);
z__b_get_option_description(opt, desc_str); z__b_get_option_description(opt, desc_str);
size_t opt_len size_t opt_len = b_string_get_size(
= b_string_get_size(opt_str, B_STRLEN_IGNORE_ESC | B_STRLEN_IGNORE_MOD) + 4; opt_str, B_STRLEN_IGNORE_ESC
| B_STRLEN_IGNORE_MOD)
+ 4;
size_t desc_len = b_string_get_size( size_t desc_len = b_string_get_size(
desc_str, B_STRLEN_IGNORE_ESC | B_STRLEN_IGNORE_MOD); 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; size_t i = 0;
b_queue_foreach (&it, &cmd->b_opt) { 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) { if (!opt) {
continue; 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_usage_string(opt, CMD_STR_COLOUR, opt_str);
z__b_get_option_description(opt, desc_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(
size_t desc_len = b_string_get_size(desc_str, B_STRLEN_IGNORE_ESC | B_STRLEN_IGNORE_MOD); 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 bool new_paragraph
= description_on_separate_line(opt_len, desc_len); = 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_tty_puts(OUTPUT_STREAM, 0, b_string_ptr(str)); 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) { while (len < format.p_left_margin) {
b_tty_putc(OUTPUT_STREAM, 0, ' '); b_tty_putc(OUTPUT_STREAM, 0, ' ');
len++; len++;
@@ -684,7 +696,9 @@ static void print_commands_list(struct b_command *cmd)
b_string_clear(str); b_string_clear(str);
get_command_string(sub, 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) { if (len > desb_margin) {
desb_margin = len; 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_tty_puts(OUTPUT_STREAM, 0, b_string_ptr(str)); 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) { while (len < format.p_left_margin) {
b_tty_putc(OUTPUT_STREAM, 0, ' '); b_tty_putc(OUTPUT_STREAM, 0, ' ');
len++; len++;
@@ -852,7 +869,8 @@ static void print_help(struct b_command *cmd)
b_paragraph_format format = {0}; b_paragraph_format format = {0};
if (!cmd->b_parent) { 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) { if (cmd->b_description) {