Allow to run ex command given as option string (#58).
authorDaniel Carl <danielcarl@gmx.de>
Sun, 19 Jan 2014 20:55:31 +0000 (21:55 +0100)
committerDaniel Carl <danielcarl@gmx.de>
Sun, 19 Jan 2014 21:00:14 +0000 (22:00 +0100)
doc/vimb.1
src/main.c

index 79d95d9..db0d0fb 100644 (file)
@@ -15,7 +15,13 @@ browsing-experience.
 .SH OPTIONS
 Mandatory arguments to long options are mandatory for short options too.
 .TP
-.BI "\-c, \--config " "CONFIG-FILE"
+.BI "\-C, \-\-cmd " "CMD"
+Run \fICMD\fP as ex command line right before the first page is loaded.
+Several ex commands can be used separated by "|".
+.br
+Example: `vimb --cmd "set cookie-accept=origin|set header=Referer,DNT=1"`
+.TP
+.BI "\-c, \-\-config " "CONFIG-FILE"
 Use custom configuration given as \fICONFIG-FILE\fP.
 .TP
 .BI "\-e, \-\-embed " "WINID"
index 57d7447..5a89260 100644 (file)
@@ -943,12 +943,14 @@ int main(int argc, char *argv[])
     static char *winid = NULL;
     static gboolean ver = false;
     static GError *err;
+    static char *cmd = NULL;
 
     vb.custom_config = NULL;
     static GOptionEntry opts[] = {
-        {"version", 'v', 0, G_OPTION_ARG_NONE, &ver, "Print version", NULL},
+        {"cmd", 'C', 0, G_OPTION_ARG_STRING, &cmd, "Ex command run before first page is loaded", NULL},
         {"config", 'c', 0, G_OPTION_ARG_STRING, &vb.custom_config, "Custom cufiguration file", NULL},
         {"embed", 'e', 0, G_OPTION_ARG_STRING, &winid, "Reparents to window specified by xid", NULL},
+        {"version", 'v', 0, G_OPTION_ARG_NONE, &ver, "Print version", NULL},
         {NULL}
     };
     /* Initialize GTK+ */
@@ -973,6 +975,11 @@ int main(int argc, char *argv[])
 
     init_core();
 
+    /* process the --cmd if this was given */
+    if (cmd) {
+        ex_run_string(cmd);
+    }
+
     /* command line argument: URL */
     vb_load_uri(&(Arg){VB_TARGET_CURRENT, argc > 1 ? argv[argc - 1] : NULL});