OpenXcom Forum

Contributions => Programming => Topic started by: Yankes on August 17, 2011, 01:58:42 am

Title: command line params
Post by: Yankes on August 17, 2011, 01:58:42 am
small patch that add (at last :> ) parsing args from command line.
supported commands:
-user lalala
-data kickicka
-displayWidth 444
-displayHeight 777
-fullscreen
-no-fullscreen
Title: Re: command line params
Post by: SupSuper on August 17, 2011, 02:26:43 am
"Small". :P

Mind you we've always had command line parameters, I've just been moving them to an external cfg recently because I figured that was more sane.
Title: Re: command line params
Post by: Yankes on August 17, 2011, 02:38:29 am
README.txt say something opposite ;P

[ps]
what objects YAML can accept? i send him 3 maps with bool, int and string values. i hope that dont break this :)
Title: Re: command line params
Post by: SupSuper on August 17, 2011, 04:05:20 am
You use nightly builds, you get what you pay for. :P And YAML accepts anything in the STL.

Anyways hope you don't mind but I came up with a smaller solution:
Code: [Select]
void Options::loadArgs(int argc, char** args)
{
for (int i = 1; i < argc; ++i)
{
if (argc > i + 1)
{
std::string arg = args[i];
if (arg[0] == '-' && argc > i + 1)
{
std::map<std::string, std::string>::iterator it = _options.find(arg.substr(1, arg.length()-1));
if (it != _options.end())
it->second = args[i+1];
}
else if (arg == "-data")
_dataFolder = args[i+1];
else if (arg == "-user")
_userFolder = args[i+1];
}
}
}
Title: Re: command line params
Post by: sir_nacnud on August 19, 2011, 03:43:19 am
small patch that add (at last :> ) parsing args from command line.
supported commands:
-user lalala
-data kickicka
-displayWidth 444
-displayHeight 777
-fullscreen
-no-fullscreen

Just so you know, you can fork the project on github, commit your changes, and then submit a pull request.  Github is order's of magnitude better for getting your changes submitted, reviewed, and merged in, than a forum post  :P