Enable just passing a url as the last argument without having to use a -u or --url upstream
authorRusty Lynch <rusty.lynch@intel.com>
Fri, 24 Aug 2012 23:42:47 +0000 (16:42 -0700)
committerRusty Lynch <rusty.lynch@intel.com>
Fri, 24 Aug 2012 23:42:47 +0000 (16:42 -0700)
webskeleton.c

index eac0c3b..3c94fd1 100644 (file)
@@ -202,7 +202,7 @@ static Context *create_context(const char *url, Eina_Bool fullscreen)
 int main(int argc, char *argv[])
 {
     const char *url = NULL;
-    int n = 0;
+    int n = 0, valid_option_count = 0;
     Eina_Bool fullscreen = EINA_FALSE;
 
     if (!ecore_evas_init())
@@ -236,12 +236,18 @@ int main(int argc, char *argv[])
             break;
         case 'h':
         default:
-            fprintf(stderr, "Usage: %s [--help] [--fullscreen] [--width=<w>] [--height=<d>] [--url=<u>]\n", argv[0]);
+            fprintf(stderr, "Usage: %s [--help] [--fullscreen] [--width=<w>] [--height=<d>] [URL]\n", argv[0]);
             exit(-1);
         }
+        valid_option_count++;
+    }
+    
+    if (!url) {
+        if (valid_option_count < argc - 1)
+            url = strdup(argv[argc - 1]);
+        else
+            url = DEFAULT_URL;
     }
-    if (!url)
-        url = DEFAULT_URL;
 
     Context *browser = create_context(url, fullscreen);
     Ecore_Event_Handler *handle = ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, main_signal_exit, 0);