reinstall: Use CLI::Parser to parse args
This commit is contained in:
		
							parent
							
								
									fd8206567b
								
							
						
					
					
						commit
						2736aed1fd
					
				| @ -11,11 +11,30 @@ require "formula_installer" | ||||
| require "development_tools" | ||||
| require "messages" | ||||
| require "reinstall" | ||||
| require "cli_parser" | ||||
| 
 | ||||
| module Homebrew | ||||
|   module_function | ||||
| 
 | ||||
|   def reinstall_args | ||||
|     Homebrew::CLI::Parser.new do | ||||
|       usage_banner <<~EOS | ||||
|         `reinstall` [<option(s)>] <formula>: | ||||
| 
 | ||||
|         Uninstall and then install <formula> (with existing install options). | ||||
| 
 | ||||
|         If `HOMEBREW_INSTALL_CLEANUP` is set then remove previously installed versions | ||||
|         of upgraded <formulae> as well as the HOMEBREW_CACHE for that formula. | ||||
|       EOS | ||||
|       switch "--display-times", | ||||
|         description: "Print install times for each formula at the end of the run." | ||||
|       switch :debug | ||||
|     end | ||||
|   end | ||||
| 
 | ||||
|   def reinstall | ||||
|     reinstall_args.parse | ||||
| 
 | ||||
|     FormulaInstaller.prevent_build_flags unless DevelopmentTools.installed? | ||||
| 
 | ||||
|     Install.perform_preinstall_checks | ||||
|  | ||||
| @ -22,9 +22,8 @@ describe "brew reinstall", :integration_test do | ||||
| 
 | ||||
|   it "reinstalls a Formula even when one of the options is invalid" do | ||||
|     expect { brew "reinstall", "testball", "--with-fo" } | ||||
|       .to output(/Reinstalling testball --with-foo/).to_stdout | ||||
|       .and output(/testball: this formula has no \-\-with-fo option so it will be ignored!/).to_stderr | ||||
|       .and be_a_success | ||||
|       .to output(/Error: invalid option: --with-fo/).to_stderr | ||||
|       .and be_a_failure | ||||
|   end | ||||
| 
 | ||||
|   it "refuses to reinstall a pinned Formula, but doesn't fail" do | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Gautham Goli
						Gautham Goli