cmd: fix extra comma after command name in usage help message

This commit is contained in:
2024-10-27 14:21:54 +00:00
parent f07e11ce60
commit f3cc628fd0

View File

@@ -3,7 +3,6 @@
#include <blue/cmd.h> #include <blue/cmd.h>
#include <blue/object/string.h> #include <blue/object/string.h>
#include <blue/term.h> #include <blue/term.h>
#include <ctype.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -313,20 +312,20 @@ static void get_command_string(struct b_command *cmd, b_string *out)
r++; r++;
} }
if (r == 1) {
b_string_append_cstr(out, ", ");
}
if (cmd->b_short_name) { if (cmd->b_short_name) {
if (r > 0) {
b_string_append_cstr(out, ", ");
}
b_string_append_cstrf(out, F_GREEN "-%c" F_RESET, cmd->b_short_name); b_string_append_cstrf(out, F_GREEN "-%c" F_RESET, cmd->b_short_name);
r++; r++;
} }
if (r == 2) {
b_string_append_cstr(out, ", ");
}
if (cmd->b_long_name) { if (cmd->b_long_name) {
if (r > 0) {
b_string_append_cstr(out, ", ");
}
b_string_append_cstrf(out, F_GREEN "--%s" F_RESET, cmd->b_long_name); b_string_append_cstrf(out, F_GREEN "--%s" F_RESET, cmd->b_long_name);
r++; r++;
} }