emulator: "--conf" should be first argument
authorSeokYeon Hwang <syeon.hwang@samsung.com>
Tue, 1 Nov 2016 00:58:25 +0000 (09:58 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Wed, 2 Nov 2016 08:52:00 +0000 (17:52 +0900)
"--conf" should be first argument. Do not proceed if it is not.
Print more kind usage if arguments are not valid.

Change-Id: Ifb62075f3b130974b4a54d5900289c66c772dabd
Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
tizen/src/emulator.c

index 94b0fcc..e4a1707 100644 (file)
@@ -285,7 +285,10 @@ static int emulator_main(int argc, char *argv[], char **envp)
             set_variable(argv[optind - 1], argv[optind], true);
             break;
         case 'c':
-            launch_conf_file = g_strdup(optarg);
+            if (optind == 3) {
+                // "--conf" should be a first argument
+                launch_conf_file = g_strdup(optarg);
+            }
             break;
         case 'q':
             c = -1;
@@ -297,8 +300,12 @@ static int emulator_main(int argc, char *argv[], char **envp)
     }
 
     if (!launch_conf_file && qemu_arg_index == 0) {
-        fprintf(stderr, "Usage: %s {-c|--conf} conf_file ...\n",
-                        basename(argv[0]));
+        char *executable = basename(argv[0]);
+        fprintf(stderr, "Usage: %s {-c|--conf} conf_file [--<key> <value>]...\n"
+                        "       %*s [{-q|--qemu} <QEMU_ARGS>...]\n",
+                        executable, (int)strlen(executable), "");
+        fprintf(stderr, "       %s {-q|--qemu} <QEMU_ARGS>...\n",
+                        executable);
 
         return -1;
     }