]> git.tdb.fi Git - libs/core.git/blobdiff - examples/grep.cpp
Add FileMonitor stubs for Windows
[libs/core.git] / examples / grep.cpp
index c87ee72171615ec8056adcf687f8f0e74d78b621..ca23499a2165480d1f705d5a58a9a3f40aac914a 100644 (file)
@@ -9,26 +9,20 @@ using namespace Msp;
 int main(int argc, char **argv)
 {
        bool debug = false;
+       string re_str;
        GetOpt getopt;
        getopt.add_option('d', "debug", debug, GetOpt::NO_ARG);
+       getopt.add_argument("regex", re_str, GetOpt::REQUIRED_ARG);
        getopt(argc, argv);
 
-       const vector<string> &args = getopt.get_args();
-
-       if(args.empty())
-       {
-               cerr<<"Usage: "<<argv[0]<<" <regex>\n";
-               return 1;
-       }
-
-       Regex regex(args[0]);
+       Regex regex(re_str);
        if(debug)
-               cout<<regex.disassemble();
+               cout << regex.disassemble();
        string line;
        while(getline(cin, line))
        {
                if(RegMatch match = regex.match(line))
-                       cout<<line<<'\n';
+                       cout << line << '\n';
        }
 
        return 0;