From 4c1a69f74e85c9e377e943f3b8dcdae4cd992b54 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 18 Sep 2013 16:34:14 -0400 Subject: [PATCH] main: Print error: in red bold just for fun It's easier to see. Also drop old dead ot_main() function. --- src/ostree/main.c | 11 ++++++++++- src/ostree/ot-main.c | 22 ---------------------- src/ostree/ot-main.h | 2 -- 3 files changed, 10 insertions(+), 25 deletions(-) diff --git a/src/ostree/main.c b/src/ostree/main.c index f23e8260..3e164f9e 100644 --- a/src/ostree/main.c +++ b/src/ostree/main.c @@ -26,6 +26,7 @@ #include #include +#include #include #include "ot-main.h" @@ -75,7 +76,15 @@ main (int argc, if (error != NULL) { - g_message ("%s", error->message); + int is_tty = isatty (1); + const char *prefix = ""; + const char *suffix = ""; + if (is_tty) + { + prefix = "\x1b[31m\x1b[1m"; /* red, bold */ + suffix = "\x1b[22m\x1b[0m"; /* bold off, color reset */ + } + g_printerr ("%serror: %s%s\n", prefix, suffix, error->message); g_error_free (error); } diff --git a/src/ostree/ot-main.c b/src/ostree/ot-main.c index 1138f861..35302065 100644 --- a/src/ostree/ot-main.c +++ b/src/ostree/ot-main.c @@ -262,25 +262,3 @@ ostree_run (int argc, } return 0; } - -int -ostree_main (int argc, - char **argv, - OstreeCommand *commands) -{ - GError *error = NULL; - int ret; - - ret = ostree_run (argc, argv, commands, &error); - - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED)) - ostree_usage (argv, commands, TRUE); - - if (error) - { - g_message ("%s", error->message); - g_error_free (error); - } - - return ret; -} diff --git a/src/ostree/ot-main.h b/src/ostree/ot-main.h index f1371866..49e310e8 100644 --- a/src/ostree/ot-main.h +++ b/src/ostree/ot-main.h @@ -36,8 +36,6 @@ typedef struct { int flags; /* OstreeBuiltinFlags */ } OstreeCommand; -int ostree_main (int argc, char **argv, OstreeCommand *commands); - int ostree_run (int argc, char **argv, OstreeCommand *commands, GError **error); int ostree_usage (char **argv, OstreeCommand *commands, gboolean is_error);