cmd/bump: add --installed flag
This allows users to only try to bump formulae and casks they currently have installed. It copies this behavior from the livecheck command.
This commit is contained in:
		
							parent
							
								
									3eb48a828d
								
							
						
					
					
						commit
						0979f7c35f
					
				@ -35,6 +35,8 @@ module Homebrew
 | 
			
		||||
             description: "Check only formulae."
 | 
			
		||||
      switch "--cask", "--casks",
 | 
			
		||||
             description: "Check only casks."
 | 
			
		||||
      switch "--installed",
 | 
			
		||||
             description: "Check formulae and casks that are currently installed."
 | 
			
		||||
      switch "--open-pr",
 | 
			
		||||
             description: "Open a pull request for the new version if none have been opened yet."
 | 
			
		||||
      flag   "--limit=",
 | 
			
		||||
@ -60,13 +62,21 @@ module Homebrew
 | 
			
		||||
      raise UsageError, "`--limit` must be used with either `--formula` or `--cask`."
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    formulae_and_casks = if args.formula?
 | 
			
		||||
    Homebrew.with_no_api_env do
 | 
			
		||||
      formulae_and_casks = if args.installed?
 | 
			
		||||
        formulae = args.cask? ? [] : Formula.installed
 | 
			
		||||
        casks = args.formula? ? [] : Cask::Caskroom.casks
 | 
			
		||||
        formulae + casks
 | 
			
		||||
      elsif args.named.present?
 | 
			
		||||
        if args.formula?
 | 
			
		||||
          args.named.to_formulae
 | 
			
		||||
        elsif args.cask?
 | 
			
		||||
          args.named.to_casks
 | 
			
		||||
        else
 | 
			
		||||
          args.named.to_formulae_and_casks
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      formulae_and_casks = formulae_and_casks&.sort_by do |formula_or_cask|
 | 
			
		||||
        formula_or_cask.respond_to?(:token) ? formula_or_cask.token : formula_or_cask.name
 | 
			
		||||
      end
 | 
			
		||||
@ -79,7 +89,6 @@ module Homebrew
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
    Homebrew.with_no_api_env do
 | 
			
		||||
      if formulae_and_casks.present?
 | 
			
		||||
        handle_formula_and_casks(formulae_and_casks, args)
 | 
			
		||||
      else
 | 
			
		||||
 | 
			
		||||
@ -441,6 +441,7 @@ _brew_bump() {
 | 
			
		||||
      --formula
 | 
			
		||||
      --full-name
 | 
			
		||||
      --help
 | 
			
		||||
      --installed
 | 
			
		||||
      --limit
 | 
			
		||||
      --no-pull-requests
 | 
			
		||||
      --open-pr
 | 
			
		||||
 | 
			
		||||
@ -384,6 +384,7 @@ __fish_brew_complete_arg 'bump' -l debug -d 'Display any debugging information'
 | 
			
		||||
__fish_brew_complete_arg 'bump' -l formula -d 'Check only formulae'
 | 
			
		||||
__fish_brew_complete_arg 'bump' -l full-name -d 'Print formulae/casks with fully-qualified names'
 | 
			
		||||
__fish_brew_complete_arg 'bump' -l help -d 'Show this message'
 | 
			
		||||
__fish_brew_complete_arg 'bump' -l installed -d 'Check formulae and casks that are currently installed'
 | 
			
		||||
__fish_brew_complete_arg 'bump' -l limit -d 'Limit number of package results returned'
 | 
			
		||||
__fish_brew_complete_arg 'bump' -l no-pull-requests -d 'Do not retrieve pull requests from GitHub'
 | 
			
		||||
__fish_brew_complete_arg 'bump' -l open-pr -d 'Open a pull request for the new version if none have been opened yet'
 | 
			
		||||
 | 
			
		||||
@ -495,6 +495,7 @@ _brew_bump() {
 | 
			
		||||
    '--debug[Display any debugging information]' \
 | 
			
		||||
    '--full-name[Print formulae/casks with fully-qualified names]' \
 | 
			
		||||
    '--help[Show this message]' \
 | 
			
		||||
    '--installed[Check formulae and casks that are currently installed]' \
 | 
			
		||||
    '--limit[Limit number of package results returned]' \
 | 
			
		||||
    '(--open-pr)--no-pull-requests[Do not retrieve pull requests from GitHub]' \
 | 
			
		||||
    '(--no-pull-requests)--open-pr[Open a pull request for the new version if none have been opened yet]' \
 | 
			
		||||
 | 
			
		||||
@ -1012,6 +1012,8 @@ formulae, also displays whether a pull request has been opened with the URL.
 | 
			
		||||
  Check only formulae.
 | 
			
		||||
* `--cask`:
 | 
			
		||||
  Check only casks.
 | 
			
		||||
* `--installed`:
 | 
			
		||||
  Check formulae and casks that are currently installed.
 | 
			
		||||
* `--open-pr`:
 | 
			
		||||
  Open a pull request for the new version if none have been opened yet.
 | 
			
		||||
* `--limit`:
 | 
			
		||||
 | 
			
		||||
@ -1443,6 +1443,10 @@ Check only formulae\.
 | 
			
		||||
Check only casks\.
 | 
			
		||||
.
 | 
			
		||||
.TP
 | 
			
		||||
\fB\-\-installed\fR
 | 
			
		||||
Check formulae and casks that are currently installed\.
 | 
			
		||||
.
 | 
			
		||||
.TP
 | 
			
		||||
\fB\-\-open\-pr\fR
 | 
			
		||||
Open a pull request for the new version if none have been opened yet\.
 | 
			
		||||
.
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user