[gjs] [gjs-console] Add a --command/-c argument



commit a5fc6067f01edd94b79b5e425860d4f0972b6ac6
Author: Johan Dahlin <johan gnome org>
Date:   Wed Feb 17 08:55:06 2010 -0200

    [gjs-console] Add a --command/-c argument
    
    Add a command argument which allows you to specify a program
    as a string on the command line. This is similar to what python
    does.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=610241

 gjs/console.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/gjs/console.c b/gjs/console.c
index fb3b5b7..e9cf8f9 100644
--- a/gjs/console.c
+++ b/gjs/console.c
@@ -30,8 +30,10 @@
 #include <gjs/gjs.h>
 
 static char **include_path = NULL;
+static char *command = NULL;
 
 static GOptionEntry entries[] = {
+    { "command", 'c', 0, G_OPTION_ARG_STRING, &command, "Program passed in as a string", "COMMAND" },
     { "include-path", 'I', 0, G_OPTION_ARG_STRING_ARRAY, &include_path, "Add the directory DIR to the list of directories to search for js files.", "DIR" },
     { NULL }
 };
@@ -76,9 +78,13 @@ main(int argc, char **argv)
                                          &error)) {
         g_printerr("Failed to defined ARGV: %s", error->message);
         exit(1);
-    } 
+    }
 
-    if (argc <= 1) {
+    if (command != NULL) {
+        script = command;
+        len = strlen(script);
+        filename = "<command line>";
+    } else if (argc <= 1) {
         script = g_strdup("const Console = imports.console; Console.interact();");
         len = strlen(script);
         filename = "<stdin>";



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]