Skip to content

Commit 6e9d914

Browse files
committed
feat: add --trace-file commandline option
1 parent 305c8a9 commit 6e9d914

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/cli/verifier/cli_options.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818
#ifndef AALTITOAD_CLI_OPTIONS_H
1919
#define AALTITOAD_CLI_OPTIONS_H
20+
#include "arguments.h"
2021
#include <vector>
2122
#include <argvparse.h>
2223
#include <iostream>
@@ -41,6 +42,8 @@ std::vector<option_t> get_options() {
4142
{"disable-warn",'w', argument_requirement::REQUIRE_ARG, "Disable a warning"},
4243
{"list-warn", 'W', argument_requirement::NO_ARG, "List all warnings available"},
4344
{"no-warn", 'm', argument_requirement::NO_ARG, "Disable all warnings"},
45+
46+
{"trace-file", 't', argument_requirement::REQUIRE_ARG, "Provide file to output result-traces to. Default is stdout"}, // TODO: We should output JSON formatted traces
4447
};
4548
}
4649

src/cli/verifier/main.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,20 @@ int main(int argc, char** argv) {
9999
spdlog::debug("reachability search took {0}ms", t.milliseconds_elapsed());
100100

101101
// gather and return results
102+
auto trace_file = cli_arguments["trace-file"].as_string_or_default("");
103+
auto* trace_stream = &std::cout;
104+
if(trace_file != "")
105+
trace_stream = new std::ofstream{trace_file, std::ios::app};
102106
for(auto& result : results) {
103-
std::cout << result.query << ": " << std::boolalpha << result.solution.has_value() << "\n";
107+
*trace_stream << result.query << ": " << std::boolalpha << result.solution.has_value() << "\n";
104108
if(result.solution.has_value())
105-
std::cout << result.solution.value();
109+
*trace_stream << result.solution.value(); // TODO: This should be json formatted
106110
}
107111

108112
return 0;
109113
} catch (std::exception& any) {
110114
spdlog::error(any.what());
111-
std::cout.flush();
115+
std::cout.flush(); // Flush the output streams, just to be nice
112116
std::cerr.flush();
113117
return 1;
114118
}

0 commit comments

Comments
 (0)