Add --verbose and -v arguments to ostree for details
Use the GLib debug mechanism to handle verbose output. https://bugzilla.gnome.org/show_bug.cgi?id=705905
This commit is contained in:
parent
1f8c7a2524
commit
462bcd86de
|
|
@ -47,4 +47,3 @@
|
||||||
#include <ot-checksum-utils.h>
|
#include <ot-checksum-utils.h>
|
||||||
|
|
||||||
void ot_ptrarray_add_many (GPtrArray *a, ...) G_GNUC_NULL_TERMINATED;
|
void ot_ptrarray_add_many (GPtrArray *a, ...) G_GNUC_NULL_TERMINATED;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ main (int argc,
|
||||||
|
|
||||||
if (error != NULL)
|
if (error != NULL)
|
||||||
{
|
{
|
||||||
g_printerr ("error: %s\n", error->message);
|
g_message ("%s", error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,19 @@ ostree_usage (char **argv,
|
||||||
return (is_error ? 1 : 0);
|
return (is_error ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
message_handler (const gchar *log_domain,
|
||||||
|
GLogLevelFlags log_level,
|
||||||
|
const gchar *message,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
/* Make this look like normal console output */
|
||||||
|
if (log_level & G_LOG_LEVEL_DEBUG)
|
||||||
|
g_printerr ("OT: %s\n", message);
|
||||||
|
else
|
||||||
|
g_printerr ("%s: %s\n", g_get_prgname (), message);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ostree_run (int argc,
|
ostree_run (int argc,
|
||||||
char **argv,
|
char **argv,
|
||||||
|
|
@ -79,6 +92,8 @@ ostree_run (int argc,
|
||||||
|
|
||||||
g_set_prgname (argv[0]);
|
g_set_prgname (argv[0]);
|
||||||
|
|
||||||
|
g_log_set_handler (NULL, G_LOG_LEVEL_MESSAGE, message_handler, NULL);
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
return ostree_usage (argv, commands, TRUE);
|
return ostree_usage (argv, commands, TRUE);
|
||||||
|
|
||||||
|
|
@ -122,6 +137,11 @@ ostree_run (int argc,
|
||||||
repo = argv[in] + 7;
|
repo = argv[in] + 7;
|
||||||
skip = TRUE;
|
skip = TRUE;
|
||||||
}
|
}
|
||||||
|
else if (g_str_equal (argv[in], "--verbose"))
|
||||||
|
{
|
||||||
|
g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG, message_handler, NULL);
|
||||||
|
skip = TRUE;
|
||||||
|
}
|
||||||
else if (cmd == NULL && g_str_equal (argv[in], "--version"))
|
else if (cmd == NULL && g_str_equal (argv[in], "--version"))
|
||||||
{
|
{
|
||||||
g_print ("%s\n %s\n", PACKAGE_STRING, OSTREE_FEATURES);
|
g_print ("%s\n %s\n", PACKAGE_STRING, OSTREE_FEATURES);
|
||||||
|
|
@ -146,7 +166,10 @@ ostree_run (int argc,
|
||||||
case 'h':
|
case 'h':
|
||||||
want_help = TRUE;
|
want_help = TRUE;
|
||||||
break;
|
break;
|
||||||
|
case 'v':
|
||||||
|
g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG, message_handler, NULL);
|
||||||
|
skip = TRUE;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
if (cmd == NULL)
|
if (cmd == NULL)
|
||||||
{
|
{
|
||||||
|
|
@ -201,11 +224,18 @@ ostree_run (int argc,
|
||||||
{
|
{
|
||||||
if (g_file_test ("objects", G_FILE_TEST_IS_DIR)
|
if (g_file_test ("objects", G_FILE_TEST_IS_DIR)
|
||||||
&& g_file_test ("config", G_FILE_TEST_IS_REGULAR))
|
&& g_file_test ("config", G_FILE_TEST_IS_REGULAR))
|
||||||
repo = ".";
|
{
|
||||||
|
g_debug ("Assuming repo is in current directory");
|
||||||
|
repo = ".";
|
||||||
|
}
|
||||||
else if (g_file_test (host_repo_path, G_FILE_TEST_EXISTS))
|
else if (g_file_test (host_repo_path, G_FILE_TEST_EXISTS))
|
||||||
repo = host_repo_path;
|
{
|
||||||
|
g_debug ("Assuming repo is at: %s", host_repo_path);
|
||||||
|
repo = host_repo_path;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
g_debug ("Could not automatically determine --repo");
|
||||||
g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||||
"Command requires a --repo argument");
|
"Command requires a --repo argument");
|
||||||
ostree_usage (argv, commands, TRUE);
|
ostree_usage (argv, commands, TRUE);
|
||||||
|
|
@ -244,7 +274,7 @@ ostree_main (int argc,
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
g_printerr ("%s\n", error->message);
|
g_message ("%s", error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue