cmd: report: update b_stringstream usage
This commit is contained in:
15
cmd/report.c
15
cmd/report.c
@@ -22,9 +22,7 @@ enum b_status b_arglist_report_missing_option(
|
|||||||
b_string *opt_string = b_string_create();
|
b_string *opt_string = b_string_create();
|
||||||
z__b_get_option_usage_string(opt, 0, opt_string);
|
z__b_get_option_usage_string(opt, 0, opt_string);
|
||||||
|
|
||||||
char opt_name_s[128];
|
b_stringstream *opt_name = b_stringstream_create();
|
||||||
struct b_stringstream opt_name;
|
|
||||||
b_stringstream_begin(&opt_name, opt_name_s, sizeof opt_name_s);
|
|
||||||
|
|
||||||
int opt_names = 0;
|
int opt_names = 0;
|
||||||
if (opt->opt_short_name) {
|
if (opt->opt_short_name) {
|
||||||
@@ -36,21 +34,22 @@ enum b_status b_arglist_report_missing_option(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (opt_names == 2) {
|
if (opt_names == 2) {
|
||||||
b_stringstream_addf(
|
b_stream_write_fmt(
|
||||||
&opt_name, "-%c / --%s", opt->opt_short_name,
|
opt_name, NULL, "-%c / --%s", opt->opt_short_name,
|
||||||
opt->opt_long_name);
|
opt->opt_long_name);
|
||||||
} else if (opt->opt_short_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) {
|
} 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.",
|
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("usage: %s", b_string_ptr(opt_string));
|
||||||
b_i("for more information, use `" F_YELLOW "--help" F_RESET "`");
|
b_i("for more information, use `" F_YELLOW "--help" F_RESET "`");
|
||||||
|
|
||||||
b_string_unref(opt_string);
|
b_string_unref(opt_string);
|
||||||
|
b_stringstream_unref(opt_name);
|
||||||
|
|
||||||
return B_SUCCESS;
|
return B_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user