cmd: report: update b_stringstream usage

This commit is contained in:
2025-10-24 12:42:38 +01:00
parent f50b2216c0
commit 57361b7dae

View File

@@ -22,9 +22,7 @@ enum b_status b_arglist_report_missing_option(
b_string *opt_string = b_string_create();
z__b_get_option_usage_string(opt, 0, opt_string);
char opt_name_s[128];
struct b_stringstream opt_name;
b_stringstream_begin(&opt_name, opt_name_s, sizeof opt_name_s);
b_stringstream *opt_name = b_stringstream_create();
int opt_names = 0;
if (opt->opt_short_name) {
@@ -36,21 +34,22 @@ enum b_status b_arglist_report_missing_option(
}
if (opt_names == 2) {
b_stringstream_addf(
&opt_name, "-%c / --%s", opt->opt_short_name,
b_stream_write_fmt(
opt_name, NULL, "-%c / --%s", opt->opt_short_name,
opt->opt_long_name);
} else if (opt->opt_short_name) {
b_stringstream_addf(&opt_name, "-%c", opt->opt_short_name);
b_stream_write_fmt(opt_name, NULL, "-%c", opt->opt_short_name);
} else if (opt->opt_long_name) {
b_stringstream_addf(&opt_name, "--%s", opt->opt_long_name);
b_stream_write_fmt(opt_name, NULL, "--%s", opt->opt_long_name);
}
b_err("required option `" F_YELLOW "%s" F_RESET "` was not specified.",
opt_name_s);
b_stringstream_ptr(opt_name));
b_i("usage: %s", b_string_ptr(opt_string));
b_i("for more information, use `" F_YELLOW "--help" F_RESET "`");
b_string_unref(opt_string);
b_stringstream_unref(opt_name);
return B_SUCCESS;
}