]> git.tdb.fi Git - libs/core.git/blobdiff - examples/grep.cpp
Fix references to deprecated functions
[libs/core.git] / examples / grep.cpp
index c87ee72171615ec8056adcf687f8f0e74d78b621..66d70f3a486fe6801b7b95ad970cf1a554a48726 100644 (file)
@@ -9,19 +9,13 @@ 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();
        string line;