mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 14:42:44 +00:00 
			
		
		
		
	Userland: Use Core::ArgsParser for 'basename'
This commit is contained in:
		
							parent
							
								
									14db94f44b
								
							
						
					
					
						commit
						9b07defb36
					
				
					 1 changed files with 8 additions and 5 deletions
				
			
		|  | @ -25,6 +25,7 @@ | |||
|  */ | ||||
| 
 | ||||
| #include <AK/LexicalPath.h> | ||||
| #include <LibCore/ArgsParser.h> | ||||
| #include <stdio.h> | ||||
| 
 | ||||
| int main(int argc, char** argv) | ||||
|  | @ -34,10 +35,12 @@ int main(int argc, char** argv) | |||
|         return 1; | ||||
|     } | ||||
| 
 | ||||
|     if (argc != 2) { | ||||
|         printf("usage: basename <path>\n"); | ||||
|         return 1; | ||||
|     } | ||||
|     printf("%s\n", LexicalPath(argv[1]).basename().characters()); | ||||
|     const char* path = nullptr; | ||||
| 
 | ||||
|     Core::ArgsParser args_parser; | ||||
|     args_parser.add_positional_argument(path, "Path to get basename from", "path"); | ||||
|     args_parser.parse(argc, argv); | ||||
| 
 | ||||
|     printf("%s\n", LexicalPath(path).basename().characters()); | ||||
|     return 0; | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Linus Groh
						Linus Groh