[ostree] --help should always go to stdout



commit 3400f2d2aef70ae9abc319ddb73ed407befbe528
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Thu Sep 25 02:34:30 2014 -0400

    --help should always go to stdout
    
    The standard convention is that the  output of --help should go to standard
    output (so that it can be piped to a pager and searched.) See, e.g., the
    GNU coding standards.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=737194

 src/ostree/ot-admin-builtin-instutil.c |    8 +++++---
 src/ostree/ot-builtin-admin.c          |    8 +++++---
 src/ostree/ot-main.c                   |    2 +-
 3 files changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/src/ostree/ot-admin-builtin-instutil.c b/src/ostree/ot-admin-builtin-instutil.c
index c87ffa4..a0a29d2 100644
--- a/src/ostree/ot-admin-builtin-instutil.c
+++ b/src/ostree/ot-admin-builtin-instutil.c
@@ -119,12 +119,14 @@ ot_admin_builtin_instutil (int argc, char **argv, OstreeSysroot *sysroot, GCance
 
   if (subcommand_name == NULL)
     {
+      void (*print_func) (const gchar *format, ...) = want_help ? g_print : g_printerr;
+
       subcommand = admin_instutil_subcommands;
-      g_print ("usage: ostree admin instutil COMMAND [options]\n");
-      g_print ("Builtin commands:\n");
+      print_func ("usage: ostree admin instutil COMMAND [options]\n");
+      print_func ("Builtin commands:\n");
       while (subcommand->name)
         {
-          g_print ("  %s\n", subcommand->name);
+          print_func ("  %s\n", subcommand->name);
           subcommand++;
         }
 
diff --git a/src/ostree/ot-builtin-admin.c b/src/ostree/ot-builtin-admin.c
index ef54797..afc3bb3 100644
--- a/src/ostree/ot-builtin-admin.c
+++ b/src/ostree/ot-builtin-admin.c
@@ -147,12 +147,14 @@ ostree_builtin_admin (int argc, char **argv, OstreeRepo *repo, GCancellable *can
 
   if (subcommand_name == NULL)
     {
+      void (*print_func) (const gchar *format, ...) = want_help ? g_print : g_printerr;
+
       subcommand = admin_subcommands;
-      g_print ("usage: ostree admin --sysroot=PATH COMMAND [options]\n");
-      g_print ("Builtin commands:\n");
+      print_func ("usage: ostree admin --sysroot=PATH COMMAND [options]\n");
+      print_func ("Builtin commands:\n");
       while (subcommand->name)
         {
-          g_print ("  %s\n", subcommand->name);
+          print_func ("  %s\n", subcommand->name);
           subcommand++;
         }
 
diff --git a/src/ostree/ot-main.c b/src/ostree/ot-main.c
index 6adb2d2..585e44f 100644
--- a/src/ostree/ot-main.c
+++ b/src/ostree/ot-main.c
@@ -201,7 +201,7 @@ ostree_run (int    argc,
           g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_FAILED,
                                "No command specified");
         }
-      ostree_usage (argv, commands, TRUE);
+      ostree_usage (argv, commands, !want_help);
       goto out;
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]