From 484db875ec39547c669e7dbeef3a3ea9628fcba8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net>
Date: Wed, 29 Jan 1997 19:39:21 -0800
Subject: [PATCH] --help and --execute added, also runs hilfe if no argument is
 given

Rev: lib/master.pike:1.21
---
 lib/master.pike | 43 +++++++++++++++++++++++++++++++++----------
 1 file changed, 33 insertions(+), 10 deletions(-)

diff --git a/lib/master.pike b/lib/master.pike
index 215964e5ef..e1e5174136 100644
--- a/lib/master.pike
+++ b/lib/master.pike
@@ -245,30 +245,53 @@ void _main(string *argv, string *env)
 
   foreach(tmp->find_all_options(argv,({
     ({"version",tmp->NO_ARG,({"-v","--version"})}),
-      ({"ignore",tmp->HAS_ARG,"-ms"}),
-	({"ignore",tmp->MAY_HAVE_ARG,"-Ddatp",0,1})}),1),
+      ({"help",tmp->NO_ARG,({"-h","--help"})}),
+	({"execute",tmp->HAS_ARG,({"-e","--execute"})}),
+	  ({"ignore",tmp->HAS_ARG,"-ms"}),
+	    ({"ignore",tmp->MAY_HAVE_ARG,"-Ddatpl",0,1})}),1),
 	  mixed *opts)
     {
       switch(opts[0])
       {
       case "version":
-	werror(version() + " Copyright (C) 1994-1997 Fredrik H�binette\n");
-	werror("Pike comes with ABSOLUTELY NO WARRANTY; This is free software and you are\n");
-	werror("welcome to redistribute it under certain conditions; Read the files\n");
-	werror("COPYING and DISCLAIMER in the Pike distribution for more details.\n");
+	werror(version() + " Copyright (C) 1994-1997 Fredrik H�binette\n"
+	       "Pike comes with ABSOLUTELY NO WARRANTY; This is free software and you are\n"
+	       "welcome to redistribute it under certain conditions; Read the files\n"
+	       "COPYING and DISCLAIMER in the Pike distribution for more details.\n");
 	exit(0);
+
+      case "help":
+	werror("Usage: pike [-driver options] script [script arguments]\n"
+	       "Driver options include:\n"
+	       " -e --execute <cmd>   : Run the given command instead of a script.\n"
+	       " -h --help            : see this message\n"
+	       " -v --version         : See what version of pike you have.\n"
+	       " -s#                  : Set stack size\n"
+	       " -m <file>            : Use <file> as master object.\n"
+	       " -d -d#               : Increase debug (# is how much)\n"
+	       " -t -t#               : Increase trace level\n"
+	  );
+	exit(0);
+
+      case "execute":
+	compile_string("#include <simulate.h>\nmixed create(){"+opts[1]+";}")();
+	exit(0);
+
       case "ignore":
 	break;
       }
     }
 
-  argv=tmp->get_args(argv,1)[1..];
+  argv=tmp->get_args(argv,1);
   destruct(tmp);
 
-  if(!sizeof(argv))
+  if(sizeof(argv)==1)
   {
-    werror("Usage: pike [-driver options] script [script arguments]\n");
-    exit(1);
+    argv=argv[0]/"/";
+    argv[-1]="hilfe";
+    argv=({ argv*"/" });
+  }else{
+    argv=argv[1..];
   }
   script=(object)argv[0];
 
-- 
GitLab