Skip to content
Permalink
Browse files

Return non-error code for given command line parameters.

  • Loading branch information
denisfa authored and rkitover committed Mar 14, 2019
1 parent 3fd444d commit a57e51f699117bd4d7e84362aa21a7935be57b29
Showing with 31 additions and 4 deletions.
  1. +28 −4 src/wx/wxvbam.cpp
  2. +3 −0 src/wx/wxvbam.h
@@ -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__)
@@ -83,6 +83,8 @@ class wxvbamApp : public wxApp {
{
}
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 @@ class wxvbamApp : public wxApp {

protected:
bool using_wayland;
bool console_mode = false;

private:
wxPathList config_path;

0 comments on commit a57e51f

Please sign in to comment.
You can’t perform that action at this time.