@@ -174,7 +174,7 @@ int main(int argc, char* argv[])
174174 std::unordered_map<runcpp2::CmdOptions, std::string> currentOptions;
175175
176176 {
177- static_assert (static_cast <int >(runcpp2::CmdOptions::COUNT) == 11 , " Update this" );
177+ static_assert (static_cast <int >(runcpp2::CmdOptions::COUNT) == 12 , " Update this" );
178178 std::unordered_map<std::string, runcpp2::OptionInfo> longOptionsMap =
179179 {
180180 {
@@ -216,10 +216,14 @@ int main(int argc, char* argv[])
216216 {
217217 " --build" ,
218218 runcpp2::OptionInfo (runcpp2::CmdOptions::BUILD, false )
219+ },
220+ {
221+ " --version" ,
222+ runcpp2::OptionInfo (runcpp2::CmdOptions::VERSION, false )
219223 }
220224 };
221225
222- static_assert (static_cast <int >(runcpp2::CmdOptions::COUNT) == 11 , " Update this" );
226+ static_assert (static_cast <int >(runcpp2::CmdOptions::COUNT) == 12 , " Update this" );
223227 std::unordered_map<std::string, const runcpp2::OptionInfo&> shortOptionsMap =
224228 {
225229 {" -r" , longOptionsMap.at (" --reset-cache" )},
@@ -231,7 +235,8 @@ int main(int argc, char* argv[])
231235 {" -s" , longOptionsMap.at (" --show-config-path" )},
232236 {" -t" , longOptionsMap.at (" --create-script-template" )},
233237 {" -w" , longOptionsMap.at (" --watch" )},
234- {" -b" , longOptionsMap.at (" --build" )}
238+ {" -b" , longOptionsMap.at (" --build" )},
239+ {" -v" , longOptionsMap.at (" --version" )}
235240 };
236241
237242 currentArgIndex = ParseArgs (longOptionsMap, shortOptionsMap, currentOptions, argc, argv);
@@ -248,7 +253,7 @@ int main(int argc, char* argv[])
248253 // Help message
249254 if (currentOptions.count (runcpp2::CmdOptions::HELP))
250255 {
251- static_assert (static_cast <int >(runcpp2::CmdOptions::COUNT) == 11 , " Update this" );
256+ static_assert (static_cast <int >(runcpp2::CmdOptions::COUNT) == 12 , " Update this" );
252257 ssLOG_BASE (" Usage: runcpp2 [options] [input_file]" );
253258 ssLOG_BASE (" Options:" );
254259 ssLOG_BASE (" -r, --[r]eset-cache Deletes all cache and build everything from scratch" );
@@ -261,6 +266,7 @@ int main(int argc, char* argv[])
261266 ssLOG_BASE (" -t, --create-script-[t]emplate <file> Creates/prepend runcpp2 script info template" );
262267 ssLOG_BASE (" -w, --[w]atch Watch script changes and output any compiling errors" );
263268 ssLOG_BASE (" -b, --[b]uild Build the script and copy output files to the working directory" );
269+ ssLOG_BASE (" -v, --[v]ersion Show the version of runcpp2" );
264270
265271 return 0 ;
266272 }
@@ -271,6 +277,13 @@ int main(int argc, char* argv[])
271277 ssLOG_BASE (runcpp2::GetConfigFilePath ());
272278 return 0 ;
273279 }
280+
281+ // Check if the version flag is present
282+ if (currentOptions.count (runcpp2::CmdOptions::VERSION))
283+ {
284+ ssLOG_BASE (" runcpp2 version " << RUNCPP2_VERSION);
285+ return 0 ;
286+ }
274287
275288 // Resetting user config
276289 if (currentOptions.count (runcpp2::CmdOptions::RESET_USER_CONFIG))
@@ -415,3 +428,4 @@ int main(int argc, char* argv[])
415428
416429 return result;
417430}
431+
0 commit comments