Avoid re-defining #formula?
This commit is contained in:
		
							parent
							
								
									3a4243742f
								
							
						
					
					
						commit
						3ea76b8498
					
				@ -55,9 +55,15 @@ module Homebrew
 | 
			
		||||
      sig { returns(T::Boolean) }
 | 
			
		||||
      def build_from_source? = false
 | 
			
		||||
 | 
			
		||||
      sig { returns(T::Boolean) }
 | 
			
		||||
      def cask? = false
 | 
			
		||||
 | 
			
		||||
      sig { returns(T::Boolean) }
 | 
			
		||||
      def force_bottle? = false
 | 
			
		||||
 | 
			
		||||
      # Defined in extend/os:
 | 
			
		||||
      # def formula; end
 | 
			
		||||
 | 
			
		||||
      sig { returns(T::Boolean) }
 | 
			
		||||
      def HEAD? = false
 | 
			
		||||
 | 
			
		||||
@ -122,9 +128,9 @@ module Homebrew
 | 
			
		||||
 | 
			
		||||
      sig { returns(T.nilable(Symbol)) }
 | 
			
		||||
      def only_formula_or_cask
 | 
			
		||||
        if invoke_if_respond_to(:formula?) && !invoke_if_respond_to(:cask?)
 | 
			
		||||
        if formula? && !cask?
 | 
			
		||||
          :formula
 | 
			
		||||
        elsif invoke_if_respond_to(:cask?) && !invoke_if_respond_to(:formula?)
 | 
			
		||||
        elsif cask? && !formula?
 | 
			
		||||
          :cask
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
@ -393,10 +393,7 @@ module Homebrew
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        unless ignore_invalid_options
 | 
			
		||||
          unless @is_dev_cmd
 | 
			
		||||
            set_default_options
 | 
			
		||||
            validate_options
 | 
			
		||||
          end
 | 
			
		||||
          validate_options unless @is_dev_cmd
 | 
			
		||||
          check_constraint_violations
 | 
			
		||||
          check_named_args(named_args)
 | 
			
		||||
        end
 | 
			
		||||
@ -416,9 +413,6 @@ module Homebrew
 | 
			
		||||
        @args
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      sig { void }
 | 
			
		||||
      def set_default_options; end
 | 
			
		||||
 | 
			
		||||
      sig { void }
 | 
			
		||||
      def validate_options; end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -9,15 +9,9 @@ module OS
 | 
			
		||||
 | 
			
		||||
        requires_ancestor { Homebrew::CLI::Parser }
 | 
			
		||||
 | 
			
		||||
        sig { void }
 | 
			
		||||
        def set_default_options
 | 
			
		||||
          args.define_singleton_method(:formula?) { true } if args.respond_to?(:formula?)
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        sig { void }
 | 
			
		||||
        def validate_options
 | 
			
		||||
          return unless args.respond_to?(:cask?)
 | 
			
		||||
          return unless T.unsafe(args).cask?
 | 
			
		||||
          return unless args.cask?
 | 
			
		||||
 | 
			
		||||
          # NOTE: We don't raise an error here because we don't want
 | 
			
		||||
          #       to print the help page or a stack trace.
 | 
			
		||||
 | 
			
		||||
@ -2,3 +2,12 @@
 | 
			
		||||
# frozen_string_literal: true
 | 
			
		||||
 | 
			
		||||
require "extend/os/linux/cli/parser" if OS.linux?
 | 
			
		||||
 | 
			
		||||
module Homebrew
 | 
			
		||||
  module CLI
 | 
			
		||||
    class Args
 | 
			
		||||
      sig { returns(T::Boolean) }
 | 
			
		||||
      def formula? = OS.linux?
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user