Commit 58e5b625 authored by ussrhero's avatar ussrhero
Browse files

fixed bug #3

parent 5eb3a61c
...@@ -38,19 +38,16 @@ Options::Options(const std::string& cmdline) : ...@@ -38,19 +38,16 @@ Options::Options(const std::string& cmdline) :
showHelp(false), showHelp(false),
runModule(false) runModule(false)
{ {
args = getArgsList( cmdline ); args = getArgsList( cmdline );
if ( args.empty() ) bool globalByDefault = true;
{
global = true;
}
for (auto it = args.begin(); it != args.end();) for (auto it = args.begin(); it != args.end();)
{ {
if (*it == "--global" || *it == "-g") if (*it == "--global" || *it == "-g")
{ {
global = true; global = true;
globalByDefault = false;
it = args.erase(it); it = args.erase(it);
continue; continue;
} }
...@@ -58,41 +55,52 @@ Options::Options(const std::string& cmdline) : ...@@ -58,41 +55,52 @@ Options::Options(const std::string& cmdline) :
if (*it == "--local" || *it == "-l") if (*it == "--local" || *it == "-l")
{ {
global = false; global = false;
globalByDefault = false;
it = args.erase(it); it = args.erase(it);
continue; continue;
} }
if (*it == "--help" || *it == "-h") std::smatch mres;
if (std::regex_match(*it, mres, versionRe))
{ {
showHelp = true; pyMajorVersion = atol(std::string(mres[1].first, mres[1].second).c_str());
if (mres[2].matched)
{
pyMinorVersion = atol(std::string(mres[2].first, mres[2].second).c_str());
}
it = args.erase(it); it = args.erase(it);
continue; continue;
} }
if (*it == "--module" || *it == "-m") break;
}
if ( args.empty() && globalByDefault)
{ {
runModule = true; global = true;
it = args.erase(it);
continue;
} }
std::smatch mres; for (auto it = args.begin(); it != args.end();)
if (std::regex_match(*it, mres, versionRe))
{ {
pyMajorVersion = atol(std::string(mres[1].first, mres[1].second).c_str());
if (mres[2].matched) if (*it == "--help" || *it == "-h")
{ {
pyMinorVersion = atol(std::string(mres[2].first, mres[2].second).c_str()); showHelp = true;
it = args.erase(it);
continue;
} }
if (*it == "--module" || *it == "-m")
{
runModule = true;
it = args.erase(it); it = args.erase(it);
continue; continue;
} }
break; break;
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment