/* $Id$ */
#include <iostream>
#include <string>
+#include <msp/core/getopt.h>
#include "regex.h"
using namespace std;
int main(int argc, char **argv)
{
- if(argc<2)
+ bool debug=false;
+ GetOpt getopt;
+ getopt.add_option('d', "debug", debug, GetOpt::NO_ARG);
+ getopt(argc, argv);
+
+ const list<string> &args=getopt.get_args();
+
+ if(args.empty())
{
cerr<<"Usage: "<<argv[0]<<" <regex>\n";
return 1;
}
Regex regex(argv[1]);
- cout<<regex.disassemble();
+ if(debug)
+ cout<<regex.disassemble();
string line;
while(getline(cin, line))
{
if(RegMatch match=regex.match(line))
- {
cout<<line<<'\n';
- }
}
return 0;