mirror of
https://github.com/ostreedev/ostree.git
synced 2025-03-19 22:50:35 +03:00
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 <string.h>
|
||||
#include <unistd.h>
|
||||
#include <locale.h>
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user