Author Topic: command line params  (Read 7613 times)

Online Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3348
    • View Profile
command line params
« 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

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2162
    • View Profile
Re: command line params
« Reply #1 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.

Online Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3348
    • View Profile
Re: command line params
« Reply #2 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 :)
« Last Edit: August 17, 2011, 02:46:58 am by Yankes »

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2162
    • View Profile
Re: command line params
« Reply #3 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];
}
}
}

Offline sir_nacnud

  • Captain
  • ***
  • Posts: 54
    • View Profile
Re: command line params
« Reply #4 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