diff --git a/src/common/main.cxx b/src/common/main.cxx index e0ff11f93..a4f2dc60c 100644 --- a/src/common/main.cxx +++ b/src/common/main.cxx @@ -153,6 +153,26 @@ bool isProfilingRun(int ac, char* av[]) { return string(av[1]) == "-profile"; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void attachConsole() +{ +#if defined(BSPF_WINDOWS) + // Attach console to allow command line output (e.g. for -help) + AttachConsole(ATTACH_PARENT_PROCESS); + FILE* fDummy; + freopen_s(&fDummy, "CONOUT$", "w", stdout); +#endif +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void freeConsole() +{ +#if defined(BSPF_WINDOWS) + cout << "Press \"Control + C\"" << std::flush; + FreeConsole(); +#endif +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #if defined(BSPF_MACOS) int stellaMain(int ac, char* av[]) @@ -219,22 +239,27 @@ int main(int ac, char* av[]) string romfile = localOpts["ROMFILE"].toString(); if(localOpts["listrominfo"].toBool()) { + attachConsole(); Logger::debug("Showing output from 'listrominfo' ..."); theOSystem->propSet().print(); + freeConsole(); return Cleanup(); } else if(localOpts["rominfo"].toBool()) { + attachConsole(); Logger::debug("Showing output from 'rominfo' ..."); FSNode romnode(romfile); Logger::error(theOSystem->getROMInfo(romnode)); - + freeConsole(); return Cleanup(); } else if(localOpts["help"].toBool()) { + attachConsole(); Logger::debug("Displaying usage"); theOSystem->settings().usage(); + freeConsole(); return Cleanup(); }