Return non-error code for given command line parameters.

This commit is contained in:
Edênis Freindorfer Azevedo 2019-03-14 16:12:48 -03:00 committed by Rafael Kitover
parent 3fd444da91
commit a57e51f699
2 changed files with 31 additions and 4 deletions

View File

@ -421,6 +421,26 @@ bool wxvbamApp::OnInit()
return true;
}
int wxvbamApp::OnRun()
{
if (console_mode)
{
// we could check for our own error codes here...
return EXIT_SUCCESS;
}
else
{
return wxApp::OnRun();
}
}
bool wxvbamApp::OnCmdLineHelp(wxCmdLineParser& parser)
{
wxApp::OnCmdLineHelp(parser);
console_mode = true;
return true;
}
void wxvbamApp::OnInitCmdLine(wxCmdLineParser& cl)
{
wxApp::OnInitCmdLine(cl);
@ -505,7 +525,8 @@ bool wxvbamApp::OnCmdLineParsed(wxCmdLineParser& cl)
s.mb_str());
tack_full_path(lm);
wxLogMessage(lm);
return false;
console_mode = true;
return true;
}
if (cl.Found(wxT("print-cfg-path"))) {
@ -515,7 +536,8 @@ bool wxvbamApp::OnCmdLineParsed(wxCmdLineParser& cl)
wxString lm(_("Configuration is read from, in order:"));
tack_full_path(lm);
wxLogMessage(lm);
return false;
console_mode = true;
return true;
}
if (cl.Found(wxT("save-over"), &s)) {
@ -533,7 +555,8 @@ bool wxvbamApp::OnCmdLineParsed(wxCmdLineParser& cl)
tack_full_path(lm, oi);
lm.append(_("\n\tbuilt-in"));
wxLogMessage(lm);
return false;
console_mode = true;
return true;
}
if (cl.Found(wxT("f"))) {
@ -567,7 +590,8 @@ bool wxvbamApp::OnCmdLineParsed(wxCmdLineParser& cl)
for (int i = 0; i < ncmds; i++)
wxPrintf(wxT("%s (%s)\n"), cmdtab[i].cmd, cmdtab[i].name);
return false;
console_mode = true;
return true;
}
#if !defined(NO_LINK) && !defined(__WXMSW__)

View File

@ -83,6 +83,8 @@ public:
{
}
virtual bool OnInit();
virtual int OnRun();
virtual bool OnCmdLineHelp(wxCmdLineParser&);
virtual bool UsingWayland() { return using_wayland; }
virtual void OnInitCmdLine(wxCmdLineParser&);
virtual bool OnCmdLineParsed(wxCmdLineParser&);
@ -140,6 +142,7 @@ public:
protected:
bool using_wayland;
bool console_mode = false;
private:
wxPathList config_path;