main: Print error: in red bold just for fun
It's easier to see. Also drop old dead ot_main() function.
This commit is contained in:
parent
58a8d6d6ef
commit
4c1a69f74e
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
|
||||||
#include "ot-main.h"
|
#include "ot-main.h"
|
||||||
|
|
@ -75,7 +76,15 @@ main (int argc,
|
||||||
|
|
||||||
if (error != NULL)
|
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);
|
g_error_free (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -262,25 +262,3 @@ ostree_run (int argc,
|
||||||
}
|
}
|
||||||
return 0;
|
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;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,6 @@ typedef struct {
|
||||||
int flags; /* OstreeBuiltinFlags */
|
int flags; /* OstreeBuiltinFlags */
|
||||||
} OstreeCommand;
|
} OstreeCommand;
|
||||||
|
|
||||||
int ostree_main (int argc, char **argv, OstreeCommand *commands);
|
|
||||||
|
|
||||||
int ostree_run (int argc, char **argv, OstreeCommand *commands, GError **error);
|
int ostree_run (int argc, char **argv, OstreeCommand *commands, GError **error);
|
||||||
|
|
||||||
int ostree_usage (char **argv, OstreeCommand *commands, gboolean is_error);
|
int ostree_usage (char **argv, OstreeCommand *commands, gboolean is_error);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue