mirror of
https://github.com/etlegacy/Update-Installer.git
synced 2024-11-10 06:31:49 +00:00
Allow the --version argument to be used when running updater.exe from a console under Windows
Attach to the parent process's console and re-open stdout/stderr before attempting to print the version number.
This commit is contained in:
parent
c9543e59f6
commit
60357cada9
1 changed files with 12 additions and 0 deletions
12
src/main.cpp
12
src/main.cpp
|
@ -86,6 +86,17 @@ bool unpackBundle(int argc, char** argv)
|
|||
}
|
||||
#endif
|
||||
|
||||
void setupConsole()
|
||||
{
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
// see http://stackoverflow.com/questions/587767/how-to-output-to-console-in-c-windows
|
||||
// and http://www.libsdl.org/cgi/docwiki.cgi/FAQ_Console
|
||||
AttachConsole(ATTACH_PARENT_PROCESS);
|
||||
freopen( "CON", "w", stdout );
|
||||
freopen( "CON", "w", stderr );
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
#ifdef PLATFORM_MAC
|
||||
|
@ -108,6 +119,7 @@ int main(int argc, char** argv)
|
|||
options.parse(argc,argv);
|
||||
if (options.showVersion)
|
||||
{
|
||||
setupConsole();
|
||||
std::cout << "Update installer version " << UPDATER_VERSION << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue