mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 05:32:44 +00:00 
			
		
		
		
	UE: Use Vector<String> for the command-line arguments
Core::ArgsParser gained support for String a while ago. So let's use that.
This commit is contained in:
		
							parent
							
								
									c2d9cd8d53
								
							
						
					
					
						commit
						26e711f953
					
				
					 1 changed files with 4 additions and 9 deletions
				
			
		|  | @ -19,27 +19,22 @@ bool g_report_to_debug = false; | |||
| 
 | ||||
| int main(int argc, char** argv, char** env) | ||||
| { | ||||
|     Vector<const char*> command; | ||||
|     Vector<String> arguments; | ||||
| 
 | ||||
|     Core::ArgsParser parser; | ||||
|     parser.add_option(g_report_to_debug, "Write reports to the debug log", "report-to-debug", 0); | ||||
|     parser.add_positional_argument(command, "Command to emulate", "command"); | ||||
|     parser.add_positional_argument(arguments, "Command to emulate", "command"); | ||||
|     parser.parse(argc, argv); | ||||
| 
 | ||||
|     auto executable_path = Core::find_executable_in_path(command[0]); | ||||
|     auto executable_path = Core::find_executable_in_path(arguments[0]); | ||||
|     if (executable_path.is_empty()) { | ||||
|         executable_path = Core::File::real_path_for(command[0]); | ||||
|         executable_path = Core::File::real_path_for(arguments[0]); | ||||
|         if (executable_path.is_empty()) { | ||||
|             reportln("Cannot find executable for '{}'.", executable_path); | ||||
|             return 1; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     Vector<String> arguments; | ||||
|     for (auto arg : command) { | ||||
|         arguments.append(arg); | ||||
|     } | ||||
| 
 | ||||
|     Vector<String> environment; | ||||
|     for (int i = 0; env[i]; ++i) { | ||||
|         environment.append(env[i]); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Gunnar Beutner
						Gunnar Beutner