2323#include " Configuration.h"
2424#include " Output.h"
2525#include " semantic/Tool.h"
26- #include " intercept/output/Report.h"
2726
2827#include < filesystem>
2928
@@ -118,29 +117,30 @@ namespace {
118117namespace cs {
119118
120119 rust::Result<int > Command::execute () const {
120+ cs::CompilationDatabase output (configuration_.output .format , configuration_.output .content );
121+
121122 // get current compilations from the input.
122- return report_serializer_. from_json (arguments_.input )
123+ return ic::EventsDatabase::open (arguments_.input )
123124 .map <Entries>([this ](const auto &commands) {
124- spdlog::debug (" commands have read. [size: {}]" , commands.executions .size ());
125125 auto compilations = tools_.transform (commands);
126126 // remove duplicates
127127 return merge ({}, compilations);
128128 })
129- .and_then <Entries>([this ](const auto &compilations) {
129+ .and_then <Entries>([this , &output ](const auto &compilations) {
130130 // read back the current content and extend with the new elements.
131131 spdlog::debug (" compilation entries created. [size: {}]" , compilations.size ());
132132 return (arguments_.append )
133- ? output_ .from_json (arguments_.output .c_str ())
133+ ? output .from_json (arguments_.output .c_str ())
134134 .template map <Entries>([&compilations](auto old_entries) {
135135 spdlog::debug (" compilation entries have read. [size: {}]" , old_entries.size ());
136136 return merge (compilations, old_entries);
137137 })
138138 : rust::Result<Entries>(rust::Ok (compilations));
139139 })
140- .and_then <size_t >([this ](const auto &compilations) {
140+ .and_then <size_t >([this , &output ](const auto &compilations) {
141141 // write the entries into the output file.
142142 spdlog::debug (" compilation entries to output. [size: {}]" , compilations.size ());
143- return output_ .to_json (arguments_.output .c_str (), compilations);
143+ return output .to_json (arguments_.output .c_str (), compilations);
144144 })
145145 .map <int >([](auto size) {
146146 // just map to success exit code if it was successful.
@@ -159,7 +159,7 @@ namespace cs {
159159 " citnames" ,
160160 VERSION,
161161 {
162- {cs::INPUT, {1 , false , " path of the input file" , {" commands.json " }, std::nullopt }},
162+ {cs::INPUT, {1 , false , " path of the input file" , {" commands.sqlite3 " }, std::nullopt }},
163163 {cs::OUTPUT, {1 , false , " path of the result file" , {" compile_commands.json" }, std::nullopt }},
164164 {cs::CONFIG, {1 , false , " path of the config file" , std::nullopt , std::nullopt }},
165165 {cs::APPEND, {0 , false , " append to output, instead of overwrite it" , std::nullopt , std::nullopt }},
@@ -173,17 +173,16 @@ namespace cs {
173173
174174 auto arguments = into_arguments (args);
175175 auto configuration = into_configuration (args, environment);
176- auto semantic = configuration.and_then <cs::semantic::Tools>([](auto config) {
177- return semantic::Tools::from (config.compilation );
178- });
176+ auto tools = configuration
177+ .and_then <cs::semantic::Tools>([](auto config) {
178+ return semantic::Tools::from (config.compilation );
179+ });
179180
180- return rust::merge (arguments, configuration, semantic )
181+ return rust::merge (arguments, configuration, tools )
181182 .map <ps::CommandPtr>([](auto tuples) {
182- const auto &[arguments, configuration, semantic ] = tuples;
183+ const auto &[arguments, configuration, tools ] = tuples;
183184 // read the configuration
184- cs::CompilationDatabase output (configuration.output .format , configuration.output .content );
185- report::ReportSerializer report_serializer;
186- return std::make_unique<Command>(arguments, report_serializer, semantic, output);
185+ return std::make_unique<Command>(arguments, configuration, tools);
187186 });
188187 }
189188}
0 commit comments