Skip to content

Commit

Permalink
Options: Add option to print current version
Browse files Browse the repository at this point in the history
This solution is not ideal, it should be more sophisticated and
distinguish between current builds and official releases.
  • Loading branch information
blishko committed May 18, 2023
1 parent a5fd9c4 commit 1c86fb7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ set(GOLEM_VERSION_PATCH 1)
set(GOLEM_VERSION ${GOLEM_VERSION_MAJOR}.${GOLEM_VERSION_MINOR}.${GOLEM_VERSION_PATCH})
project(Golem VERSION ${GOLEM_VERSION} LANGUAGES CXX)

add_definitions(-DGOLEM_VERSION="${GOLEM_VERSION}")

set(CMAKE_CXX_STANDARD 17)

set(CMAKE_SOURCE_DIR "src")
Expand Down
10 changes: 7 additions & 3 deletions src/Options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ void printUsage() {
"Usage: golem [options] [-i] file\n"
"\n"
"-h,--help Print this help message\n"
"--version Print version number of Golem\n"
"-l,--logic <name> SMT-LIB logic to use (required); possible values: QF_LRA, QF_LIA\n"
"-e,--engine <name> Select engine to use; supported engines:\n"
" bmc - Bounded Model Checking (only transition systems)\n"
Expand Down Expand Up @@ -62,10 +63,12 @@ Options CommandLineParser::parse(int argc, char ** argv) {
int forcedCovering = 0;
int verbose = 0;
int tpaUseQE = 0;
int printVersion = 0;

struct option long_options[] =
{
{"help", no_argument, nullptr, 'h'},
{"version", no_argument, &printVersion, 1},
{Options::ENGINE.c_str(), required_argument, nullptr, 'e'},
{Options::LOGIC.c_str(), required_argument, nullptr, 'l'},
{Options::INPUT_FILE.c_str(), required_argument, nullptr, 'i'},
Expand All @@ -87,6 +90,10 @@ Options CommandLineParser::parse(int argc, char ** argv) {

switch (c) {
case 0:
if (long_options[option_index].flag == &printVersion) {
std::cout << "Golem " << GOLEM_VERSION << std::endl;
exit(0);
}
if (long_options[option_index].flag == &computeWitness and optarg) {
if (isDisableKeyword(optarg)) {
computeWitness = 0;
Expand All @@ -110,15 +117,12 @@ Options CommandLineParser::parse(int argc, char ** argv) {
break;
case 'e':
res.addOption(Options::ENGINE, optarg);
// printf ("option -e with value `%s'\n", optarg);
break;
case 'l':
res.addOption(Options::LOGIC, optarg);
// printf ("option -l with value `%s'\n", optarg);
break;
case 'i':
res.addOption(Options::INPUT_FILE, optarg);
// printf ("option -i with value `%s'\n", optarg);
break;
case 'f':
res.addOption(Options::ANALYSIS_FLOW, optarg);
Expand Down

0 comments on commit 1c86fb7

Please sign in to comment.