Skip to content

Commit

Permalink
Merge pull request #1194 from RachelBryk/arg
Browse files Browse the repository at this point in the history
If one argument is given, assume it is a game, and run it.
  • Loading branch information
skidau committed Oct 3, 2014
2 parents ed7f073 + c0270f6 commit 6333f41
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Source/Core/DolphinWX/Main.cpp
Expand Up @@ -213,14 +213,20 @@ bool DolphinApp::OnInit()

// Gets the command line parameters
wxCmdLineParser parser(cmdLineDesc, argc, argv);
if (parser.Parse() != 0)
if (argc == 2)
{
LoadFile = true;
FileToLoad = argv[1];
}
else if (parser.Parse() != 0)
{
return false;
}

UseDebugger = parser.Found("debugger");
UseLogger = parser.Found("logger");
LoadFile = parser.Found("exec", &FileToLoad);
if (!LoadFile)
LoadFile = parser.Found("exec", &FileToLoad);
BatchMode = parser.Found("batch");
selectVideoBackend = parser.Found("video_backend", &videoBackendName);
selectAudioEmulation = parser.Found("audio_emulation", &audioEmulationName);
Expand Down

3 comments on commit 6333f41

@CarlKenner
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very bad implementation. If one argument is given, it is just as likely to be -d, -h, -l, or -b. Which this has now broken. Or in my branch various other flags.
One way of fixing it would be to check if argv[1] begins with a '-'. Although that doesn't work with switches beginning with "/" on windows, which dolphin already allows.
There must be an official way of doing this with wxWidgets though.

@JMC47
Copy link
Contributor

@JMC47 JMC47 commented on 6333f41 Oct 3, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we're discussing this in IRC, many laughs were had as people realized it was broken. I expect a revert or quick fix.

@archshift
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps dolphin should use one of the many tried and tested command-line argument parsers, instead of wx's evidently bad implementation.

Please sign in to comment.