Skip to content

Commit

Permalink
add --version flag to cli arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicals committed Dec 31, 2021
1 parent 75a01ca commit 043e7fa
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions SIGNOFF
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,4 @@ Paul Bransford (draeath) <[email protected]>
Mark Langsdorf (mlangsdorf) <[email protected]> / <[email protected]>
Ratul Saha (sahaRatul) <[email protected]> / <[email protected]>
Davis Bray (Kaltag1925) <[email protected]>
Nicolas Appriou <[email protected]>
34 changes: 34 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "filesystem.h"
#include "game.h"
#include "game_ui.h"
#include "get_version.h"
#include "input.h"
#include "loading_ui.h"
#include "main_menu.h"
Expand Down Expand Up @@ -194,6 +195,34 @@ void printHelpMessage( const FirstPassArgs &first_pass_arguments,
}
}


/**
* Displays current application version and compile options values
*/
void printVersionMessage()
{
#if defined(TILES)
const bool hasTiles = true;
#else
const bool hasTiles = false;
#endif

#if defined(SDL_SOUND)
const bool hasSound = true;
#else
const bool hasSound = false;
#endif

printf( "Cataclysm Dark Days Ahead: %s\n\n"
"%ctiles, %csound\n\n"
"data dir: %s\nuser dir: %s\n",
getVersionString(),
hasTiles ? '+' : '-',
hasSound ? '+' : '-' ,
PATH_INFO::datadir().c_str(),
PATH_INFO::user_dir().c_str() );
}

template<typename ArgHandlerContainer>
void process_args( const char **argv, int argc, const ArgHandlerContainer &arg_handlers )
{
Expand Down Expand Up @@ -499,6 +528,11 @@ cli_opts parse_commandline( int argc, const char **argv )
std::exit( 0 );
}

if( std::count( argv, argv + argc, std::string( "--version" ) ) ) {
printVersionMessage();
std::exit( 0 );
}

// skip program name
--argc;
++argv;
Expand Down

0 comments on commit 043e7fa

Please sign in to comment.