From 3606f52c53898e6ac14f03d53f5d850602b310d3 Mon Sep 17 00:00:00 2001
From: David Flitney <dave.flitney@ndcn.ox.ac.uk>
Date: Fri, 17 Nov 2000 15:45:00 +0000
Subject: [PATCH] Initial revision

---
 opttst.cc | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
 create mode 100644 opttst.cc

diff --git a/opttst.cc b/opttst.cc
new file mode 100644
index 0000000..71b5a82
--- /dev/null
+++ b/opttst.cc
@@ -0,0 +1,56 @@
+
+
+
+using namespace Options;
+
+Option<bool> verbose(string("-V,--verbose"), false, 
+		     string("switch on diagnostic messages"), 
+		     false, no_argument);
+Option<bool> help(string("-h,--help"), false,
+		  string("display this message"),
+		  false, no_argument);
+Option<float> dof(string("-d,--dof"), 100.0,
+		  string("number of degrees of freedom"),
+		  true, requires_argument);
+Option<string> mask(string("-m,--mask"), string("mask"),
+		    string("brain mask volume"),
+		    true, requires_argument);
+Option<string> resid(string("-r,--res"), string("res4d"),
+		     string("4d `residual-of-fit' image"),
+		     true, requires_argument);
+
+int main(unsigned int argc, char **argv) {
+
+  OptionParser options("options", 
+		       "-d <number> --mask <filename> --res <filename>");
+
+  try {
+
+    options.add(verbose);
+    options.add(help);
+    options.add(dof);
+    options.add(mask);
+    options.add(resid);
+
+    for(unsigned int a = options.parse_command_line(argc, argv); a < argc; a++)
+      cout << argv[a] << endl;
+  
+    if(help.value())
+      options.usage();
+
+    if(verbose.value()) {
+      cout << "verbose = " << verbose.value() << endl;
+      cout << "help = " << help.value() << endl;
+      cout << "dof = " << dof.value() << endl;
+      cout << "mask = " << mask.value() << endl;
+      cout << "resid = " << resid.value() << endl;
+    }
+
+  } catch(X_OptionError& e) {
+    options.usage();
+    cerr << endl << e.what() << endl;
+  } catch(std::exception &e) {
+    cerr << e.what() << endl;
+  }    
+}
+
-- 
GitLab