r8317: convert the example scripts over to the new GetOptions() call
authorAndrew Tridgell <tridge@samba.org>
Mon, 11 Jul 2005 07:43:36 +0000 (07:43 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:20:06 +0000 (13:20 -0500)
(This used to be commit 5f079d74630cf6431ec8af7240f60054cf8b9ab7)

testprogs/ejs/argv.js
testprogs/ejs/echo.js
testprogs/ejs/nbtstats
testprogs/ejs/samr.js

index 2f8dc74174a1ffa50bb00ab156ed5eeb648cfc73..093123014a201a423f2ba0bdf3f368eea304c12a 100644 (file)
@@ -1,7 +1,18 @@
 /*
-       demonstrate use of argv
+       demonstrate use of GetOptions
 */
 
+var ok;
+var options = new Object();
+
+ok = GetOptions(ARGV, options,
+               "POPT_AUTOHELP",
+               "POPT_COMMON_SAMBA",
+               "myopt=s",
+               "intopt=i",
+               "noopt");
+printVars(ok);
+
 println("You called this script with arguments:");
 
-printVars(ARGV);
+printVars(options);
index 312e599d50b03868bd2bff2ac61e0af9866687db..e5b0b2b1bf306355416600c705ee49a57de0be33 100755 (executable)
@@ -3,6 +3,17 @@
        test echo pipe calls from ejs
 */     
 
+var options = new Object();
+
+ok = GetOptions(ARGV, options,
+               "POPT_AUTOHELP",
+               "POPT_COMMON_SAMBA",
+               "POPT_COMMON_CREDENTIALS");
+if (ok == false) {
+   println("Failed to parse options: " + options.ERROR);
+   return -1;
+}
+
 libinclude("base.js");
 
 /*
@@ -198,7 +209,11 @@ if (ARGV.length == 0) {
    exit(0);
 }
 
-var binding = ARGV[0];
+if (options.ARGV.length != 1) {
+   println("Usage: samr.js <BINDING>");
+   return -1;
+}
+var binding = options.ARGV[0];
 var conn = new Object();
 
 print("Connecting to " + binding + "\n");
index f2655e8c6e1fd8e7d771f54e59ee70242ff40db9..fe93a728cd7e7a221233332356cbf593c7261281 100755 (executable)
@@ -3,6 +3,16 @@
        demonstrate access to irpc calls from ejs
 */     
 
+var options = new Object();
+
+ok = GetOptions(ARGV, options,
+               "POPT_AUTOHELP",
+               "POPT_COMMON_SAMBA");
+if (ok == false) {
+   println("Failed to parse options: " + options.ERROR);
+   return -1;
+}
+
 var conn = new Object();
 
 status = irpc_connect(conn, "nbt_server");
index 1c613d5619794cbc7ee1a1e997264eb4ac8c757c..d0c2990158b4ef05bdc2cfba0a0728011ae10be7 100755 (executable)
@@ -3,9 +3,19 @@
   test samr calls from ejs
 */     
 
+var options = new Object();
+
+ok = GetOptions(ARGV, options,
+               "POPT_AUTOHELP",
+               "POPT_COMMON_SAMBA",
+               "POPT_COMMON_CREDENTIALS");
+if (ok == false) {
+   println("Failed to parse options: " + options.ERROR);
+   return -1;
+}
+
 libinclude("base.js");
 libinclude("samr.js");
-libinclude("samr.js");
 
 
 /*
@@ -96,14 +106,11 @@ function test_EnumDomains(conn, handle)
        }
 }
 
-
-
-if (ARGV.length == 0) {
-   print("Usage: samr.js <RPCBINDING>\n");
-   exit(0);
+if (options.ARGV.length != 1) {
+   println("Usage: samr.js <BINDING>");
+   return -1;
 }
-
-var binding = ARGV[0];
+var binding = options.ARGV[0];
 var conn = new Object();
 
 print("Connecting to " + binding + "\n");