فهرست منبع

ncd: allow specifying program file without --config-file option

ambrop7 13 سال پیش
والد
کامیت
a382f83a07
1فایلهای تغییر یافته به همراه5 افزوده شده و 1 حذف شده
  1. 5 1
      ncd/ncd.c

+ 5 - 1
ncd/ncd.c

@@ -40,6 +40,7 @@
 #include <misc/balloc.h>
 #include <misc/open_standard_streams.h>
 #include <misc/expstring.h>
+#include <misc/string_begins_with.h>
 #include <structure/LinkedList1.h>
 #include <base/BLog.h>
 #include <base/BLog_syslog.h>
@@ -507,9 +508,9 @@ void print_help (const char *name)
         "        )\n"
         "        [--loglevel <0-5/none/error/warning/notice/info/debug>]\n"
         "        [--channel-loglevel <channel-name> <0-5/none/error/warning/notice/info/debug>] ...\n"
-        "        --config-file <file>\n"
         "        [--retry-time <ms>]\n"
         "        [--no-udev]\n"
+        "        [--config-file] <file>\n"
         "        [-- [<extra_arg>] ...]\n",
         name
     );
@@ -642,6 +643,9 @@ int parse_arguments (int argc, char *argv[])
             options.num_extra_args = argc - i - 1;
             i += options.num_extra_args;
         }
+        else if (!string_begins_with(arg, "--") && !options.config_file) {
+            options.config_file = argv[i];
+        }
         else {
             fprintf(stderr, "unknown option: %s\n", arg);
             return 0;