Răsfoiți Sursa

device: exit with 0 on --version and --help

Daniele Bartolini 7 ani în urmă
părinte
comite
6649c132cd

+ 5 - 3
src/device/device_options.cpp

@@ -69,20 +69,22 @@ DeviceOptions::DeviceOptions(Allocator& a, int argc, const char** argv)
 {
 }
 
-int DeviceOptions::parse()
+int DeviceOptions::parse(bool* quit)
 {
 	CommandLine cl(_argc, _argv);
 
 	if (cl.has_option("help", 'h'))
 	{
 		help();
-		return EXIT_FAILURE;
+		*quit = true;
+		return EXIT_SUCCESS;
 	}
 
 	if (cl.has_option("version", 'v'))
 	{
 		printf("Crown " CROWN_VERSION "\n");
-		return EXIT_FAILURE;
+		*quit = true;
+		return EXIT_SUCCESS;
 	}
 
 	path::reduce(_source_dir, cl.get_parameter(0, "source-dir"));

+ 1 - 1
src/device/device_options.h

@@ -44,7 +44,7 @@ struct DeviceOptions
 
 	/// Parses the command line and returns
 	/// EXIT_SUCCESS if no error is found.
-	int parse();
+	int parse(bool* quit);
 };
 
 } // namespace crown

+ 3 - 2
src/device/main_linux.cpp

@@ -799,9 +799,10 @@ int main(int argc, char** argv)
 	CE_UNUSED(m);
 
 	DeviceOptions opts(default_allocator(), argc, (const char**)argv);
-	int ec = opts.parse();
+	bool quit = false;
+	int ec = opts.parse(&quit);
 
-	if (ec == EXIT_SUCCESS)
+	if (ec == EXIT_SUCCESS && !quit)
 		ec = s_ldvc.run(&opts);
 
 	return ec;

+ 3 - 2
src/device/main_windows.cpp

@@ -709,9 +709,10 @@ int main(int argc, char** argv)
 	CE_UNUSED(m);
 
 	DeviceOptions opts(default_allocator(), argc, (const char**)argv);
-	int ec = opts.parse();
+	bool quit = false;
+	int ec = opts.parse(&quit);
 
-	if (ec == EXIT_SUCCESS)
+	if (ec == EXIT_SUCCESS && !quit)
 		ec = s_wdvc.run(&opts);
 
 	WSACleanup();

+ 4 - 1
src/resource/data_compiler.cpp

@@ -537,7 +537,10 @@ int main_data_compiler(int argc, char** argv)
 	CE_UNUSED(m);
 
 	DeviceOptions opts(default_allocator(), argc, (const char**)argv);
-	if (opts.parse() == EXIT_FAILURE)
+	bool quit = false;
+	CE_UNUSED(quit);
+	int ec = opts.parse(&quit);
+	if (ec == EXIT_FAILURE)
 		return EXIT_FAILURE;
 
 	console_server_globals::init();