Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=cfpm.git;a=commitdiff;h=f534936a01d5f20041063ac1ef93e9c0ec483274

commit f534936a01d5f20041063ac1ef93e9c0ec483274
Author: James Buren <r...@frugalware.org>
Date:   Thu Jun 4 16:59:58 2009 -0500

args.cc
* initial draft

diff --git a/args.cc b/args.cc
new file mode 100644
index 0000000..26c0c40
--- /dev/null
+++ b/args.cc
@@ -0,0 +1,49 @@
+#include <iostream>
+#include <string>
+#include "args.hh"
+
+#define PRINT_VERSION cout << name << " version " << VERSION << endl
+#define PRINT_HELP    cout << "Usage: " << name << endl\
+                      << endl\
+                      << "Accepted arguments:" << endl\
+                      << endl\
+                      << "-v -> Print version information" << endl\
+                      << "-h -> Print this help display" << endl
+#define PRINT_DEFAULT cout << "Unrecognized argument: " << arg << endl
+
+using std::string;
+using std::cout;
+using std::endl;
+
+// Initialize to default values
+Args::Args()
+{
+       flags = 0;
+}
+
+bool Args::parseArgs(int argc,char **argv)
+{
+       const string name = argv[0];
+
+       for( int i = 1 ; i < argc ; ++i )
+       {
+               const string arg = argv[i];
+               if(arg == "-v")
+               {
+                       PRINT_VERSION;
+                       return false;
+               }
+               else if(arg == "-h")
+               {
+                       PRINT_HELP;
+                       return false;
+               }
+               else if(arg[0] == '-')
+               {
+                       PRINT_DEFAULT;
+                       return false;
+               }
+       }
+
+       return true;
+}
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to