@@ -175,7 +175,7 @@ int main(int argc, char* argv[])
175175 int currentArgIndex = 0 ;
176176 std::unordered_map<runcpp2::CmdOptions, std::string> currentOptions;
177177 {
178- static_assert (static_cast <int >(runcpp2::CmdOptions::COUNT) == 13 , " Update this" );
178+ static_assert (static_cast <int >(runcpp2::CmdOptions::COUNT) == 14 , " Update this" );
179179 std::unordered_map<std::string, runcpp2::OptionInfo> longOptionsMap =
180180 {
181181 {
@@ -225,10 +225,14 @@ int main(int argc, char* argv[])
225225 {
226226 " --log-level" ,
227227 runcpp2::OptionInfo (runcpp2::CmdOptions::LOG_LEVEL, true )
228+ },
229+ {
230+ " --config" ,
231+ runcpp2::OptionInfo (runcpp2::CmdOptions::CONFIG_FILE, true )
228232 }
229233 };
230234
231- static_assert (static_cast <int >(runcpp2::CmdOptions::COUNT) == 13 , " Update this" );
235+ static_assert (static_cast <int >(runcpp2::CmdOptions::COUNT) == 14 , " Update this" );
232236 std::unordered_map<std::string, const runcpp2::OptionInfo&> shortOptionsMap =
233237 {
234238 {" -rc" , longOptionsMap.at (" --reset-cache" )},
@@ -241,7 +245,8 @@ int main(int argc, char* argv[])
241245 {" -t" , longOptionsMap.at (" --create-script-template" )},
242246 {" -w" , longOptionsMap.at (" --watch" )},
243247 {" -b" , longOptionsMap.at (" --build" )},
244- {" -v" , longOptionsMap.at (" --version" )}
248+ {" -v" , longOptionsMap.at (" --version" )},
249+ {" -c" , longOptionsMap.at (" --config" )}
245250 };
246251
247252 currentArgIndex = ParseArgs (longOptionsMap, shortOptionsMap, currentOptions, argc, argv);
@@ -258,7 +263,7 @@ int main(int argc, char* argv[])
258263 // Help message
259264 if (currentOptions.count (runcpp2::CmdOptions::HELP))
260265 {
261- static_assert (static_cast <int >(runcpp2::CmdOptions::COUNT) == 13 , " Update this" );
266+ static_assert (static_cast <int >(runcpp2::CmdOptions::COUNT) == 14 , " Update this" );
262267 ssLOG_BASE (" Usage: runcpp2 [options] [input_file]" );
263268 ssLOG_BASE (" Options:" );
264269 ssLOG_BASE (" -rc, --[r]eset-[c]ache Deletes compiled source files cache only" );
@@ -272,6 +277,7 @@ int main(int argc, char* argv[])
272277 ssLOG_BASE (" -w, --[w]atch Watch script changes and output any compiling errors" );
273278 ssLOG_BASE (" -b, --[b]uild Build the script and copy output files to the working directory" );
274279 ssLOG_BASE (" -v, --[v]ersion Show the version of runcpp2" );
280+ ssLOG_BASE (" -c, --[c]onfig <file> Use specified config file instead of default" );
275281 ssLOG_BASE (" --log-level <level> Sets the log level (Normal, Info, Debug) for runcpp2." );
276282
277283 return 0 ;
@@ -340,12 +346,16 @@ int main(int argc, char* argv[])
340346 std::vector<runcpp2::Data::Profile> profiles;
341347 std::string preferredProfile;
342348
343- if (!runcpp2::ReadUserConfig (profiles, preferredProfile))
349+ std::string configPath;
350+ if (currentOptions.count (runcpp2::CmdOptions::CONFIG_FILE))
351+ configPath = currentOptions.at (runcpp2::CmdOptions::CONFIG_FILE);
352+
353+ if (!runcpp2::ReadUserConfig (profiles, preferredProfile, configPath))
344354 {
345355 ssLOG_ERROR (" Failed read user config" );
346356 return -1 ;
347357 }
348-
358+
349359 ssLOG_DEBUG (" \n profiles:" );
350360 for (int i = 0 ; i < profiles.size (); ++i)
351361 ssLOG_DEBUG (" \n " << profiles.at (i).ToString (" " ));
0 commit comments