Skip to content

Commit 4166bea

Browse files
eeppjgalar
authored andcommitted
cli: colorize version printing
Signed-off-by: Philippe Proulx <[email protected]> Change-Id: I76388372a3b2f11ebb2ee76020f3d224f376f604 Reviewed-on: https://review.lttng.org/c/babeltrace/+/2840 Reviewed-by: Francis Deslauriers <[email protected]> Tested-by: jenkins <[email protected]>
1 parent 72fa419 commit 4166bea

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

src/cli/babeltrace2-cfg-cli-args.c

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,24 @@ void print_version(void)
221221
bool has_extra = has_extra_name || has_extra_description ||
222222
has_extra_patch_names;
223223

224-
printf("Babeltrace " VERSION);
224+
printf("%sBabeltrace %s%s",
225+
bt_common_color_bold(),
226+
VERSION,
227+
bt_common_color_reset());
225228

226229
if (strlen(BT_VERSION_NAME) > 0) {
227-
printf(" \"%s\"", BT_VERSION_NAME);
230+
printf(" \"%s%s%s%s\"",
231+
bt_common_color_fg_bright_blue(),
232+
bt_common_color_bold(),
233+
BT_VERSION_NAME,
234+
bt_common_color_reset());
228235
}
229236

230237
if (strlen(BT_VERSION_GIT) > 0) {
231-
printf(" [%s]", BT_VERSION_GIT);
238+
printf(" [%s%s%s]",
239+
bt_common_color_fg_yellow(),
240+
BT_VERSION_GIT,
241+
bt_common_color_reset());
232242
}
233243

234244
printf("\n");
@@ -252,16 +262,23 @@ void print_version(void)
252262
printf("\n");
253263

254264
if (has_extra_name) {
255-
printf("Extra name: %s\n", BT_VERSION_EXTRA_NAME);
265+
printf("%sExtra name%s: %s\n",
266+
bt_common_color_fg_cyan(),
267+
bt_common_color_reset(),
268+
BT_VERSION_EXTRA_NAME);
256269
}
257270

258271
if (has_extra_description) {
259-
printf("Extra description:\n ");
272+
printf("%sExtra description%s:\n ",
273+
bt_common_color_fg_cyan(),
274+
bt_common_color_reset());
260275
print_and_indent(BT_VERSION_EXTRA_DESCRIPTION);
261276
}
262277

263278
if (has_extra_patch_names) {
264-
printf("Extra patch names:\n ");
279+
printf("%sExtra patch names%s:\n ",
280+
bt_common_color_fg_cyan(),
281+
bt_common_color_reset());
265282
print_and_indent(BT_VERSION_EXTRA_PATCHES);
266283
}
267284
}

0 commit comments

Comments
 (0)