Skip to content

Commit

Permalink
added --version argument which prints only the version string
Browse files Browse the repository at this point in the history
  • Loading branch information
guicho271828 committed Jan 13, 2025
1 parent 3de3090 commit 5d2b9d9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/search/command_line.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "git_revision.h"
#include "command_line.h"

#include "plan_manager.h"
Expand Down Expand Up @@ -151,6 +152,9 @@ static shared_ptr<SearchAlgorithm> parse_cmd_line_aux(const vector<string> &args
num_previously_generated_plans = parse_int_arg(arg, args[i]);
if (num_previously_generated_plans < 0)
input_error("argument for --internal-previous-portfolio-plans must be positive");
} else if (arg == "--version") {
cout << GIT_REVISION << endl;
exit(0);
} else {
input_error("unknown option " + arg);
}
Expand Down Expand Up @@ -196,6 +200,8 @@ string usage(const string &progname) {
"--help [NAME]\n"
" Prints help for all heuristics, open lists, etc. called NAME.\n"
" Without parameter: prints help for everything available\n"
"--version \n"
" Prints Git SHA1 commit revision.\n"
"--internal-plan-file FILENAME\n"
" Plan will be output to a file called FILENAME\n\n"
"--internal-previous-portfolio-plans COUNTER\n"
Expand Down
1 change: 1 addition & 0 deletions src/search/git_revision.h.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#pragma once
#define GIT_REVISION "@GIT_REVISION@"
10 changes: 7 additions & 3 deletions src/search/planner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,19 @@ int main(int argc, const char **argv) {
try {
utils::register_event_handlers();

utils::g_log << "Fast Downward build " << GIT_REVISION << endl;

if (argc < 2) {
utils::g_log << "Fast Downward build " << GIT_REVISION << endl;
utils::g_log << usage(argv[0]) << endl;
utils::exit_with(ExitCode::SEARCH_INPUT_ERROR);
}

if (static_cast<string>(argv[1]) != "--version") {
// if otherwise (argv[1] is --version), print only the version string. This is done in parse_cmd_line
utils::g_log << "Fast Downward build " << GIT_REVISION << endl;
}

bool unit_cost = false;
if (static_cast<string>(argv[1]) != "--help") {
if (static_cast<string>(argv[1]) != "--help" && static_cast<string>(argv[1]) != "--version") {
utils::g_log << "reading input..." << endl;
tasks::read_root_task(cin);
utils::g_log << "done reading input!" << endl;
Expand Down

0 comments on commit 5d2b9d9

Please sign in to comment.