]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Main: Improve BIRD help messages
authorPavel Tvrdik <pawel.tvrdik@gmail.com>
Thu, 8 Sep 2016 14:27:40 +0000 (16:27 +0200)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Thu, 15 Sep 2016 15:30:52 +0000 (17:30 +0200)
sysdep/unix/main.c

index 11a4acc6ae01ef99bab4ff318be6f3eaad1d9bea..a79899205627d87058c8afb2debff8ca767e20c4 100644 (file)
@@ -617,7 +617,7 @@ signal_init(void)
  *     Parsing of command-line arguments
  */
 
-static char *opt_list = "c:dD:ps:P:u:g:flR";
+static char *opt_list = "c:dD:ps:P:u:g:flRh";
 static int parse_and_exit;
 char *bird_name;
 static char *use_user;
@@ -625,10 +625,43 @@ static char *use_group;
 static int run_in_foreground = 0;
 
 static void
-usage(void)
+display_usage(void)
 {
-  fprintf(stderr, "Usage: %s [-c <config-file>] [-d] [-D <debug-file>] [-p] [-s <control-socket>] [-P <pid-file>] [-u <user>] [-g <group>] [-f] [-l] [-R]\n", bird_name);
-  exit(1);
+  fprintf(stderr, "Usage: %s [--version] [--help] [-c <config-file>] [OPTIONS]\n", bird_name);
+}
+
+static void
+display_help(void)
+{
+  display_usage();
+
+  fprintf(stderr,
+    "\n"
+    "Options: \n"
+    "  -c <config-file>     Use given configuration file instead\n"
+    "                       of prefix/etc/bird.conf\n"
+    "  -d                   Enable debug messages and run bird in foreground\n"
+    "  -D <debug-file>      Log debug messages to given file instead of stderr\n"
+    "  -f                   Run bird in foreground\n"
+    "  -g <group>           Use given group ID\n"
+    "  -h, --help           Display this information\n"
+    "  -l                   Look for a configuration file and a communication socket\n"
+    "                       file in the current working directory\n"
+    "  -p                   Test configuration file and exit without start\n"
+    "  -P <pid-file>        Create a PID file with given filename\n"
+    "  -R                   Apply graceful restart recovery after start\n"
+    "  -s <control-socket>  Use given filename for a control socket\n"
+    "  -u <user>            Drop privileges and use given user ID\n"
+    "  --version            Display version of BIRD\n");
+
+  exit(0);
+}
+
+static void
+display_version(void)
+{
+  fprintf(stderr, "BIRD version " BIRD_VERSION "\n");
+  exit(0);
 }
 
 static inline char *
@@ -702,12 +735,9 @@ parse_args(int argc, char **argv)
   if (argc == 2)
     {
       if (!strcmp(argv[1], "--version"))
-       {
-         fprintf(stderr, "BIRD version " BIRD_VERSION "\n");
-         exit(0);
-       }
+       display_version();
       if (!strcmp(argv[1], "--help"))
-       usage();
+       display_help();
     }
   while ((c = getopt(argc, argv, opt_list)) >= 0)
     switch (c)
@@ -751,11 +781,19 @@ parse_args(int argc, char **argv)
       case 'R':
        graceful_restart_recovery();
        break;
+      case 'h':
+       display_help();
+       break;
       default:
-       usage();
+       fputc('\n', stderr);
+       display_usage();
+       exit(1);
       }
   if (optind < argc)
-    usage();
+   {
+     display_usage();
+     exit(1);
+   }
 }
 
 /*