From b05c72b98b4ce370ce9bd8763c931a8123511e2f Mon Sep 17 00:00:00 2001 From: Gautham G Date: Sun, 12 Apr 2020 19:12:16 +0530 Subject: [PATCH] cli/args: Make build_from_source public instance method --- Library/Homebrew/cli/args.rb | 13 +++++++------ Library/Homebrew/cli/parser.rb | 2 +- Library/Homebrew/global.rb | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Library/Homebrew/cli/args.rb b/Library/Homebrew/cli/args.rb index c8620a17e9..ff6afae43f 100644 --- a/Library/Homebrew/cli/args.rb +++ b/Library/Homebrew/cli/args.rb @@ -12,6 +12,7 @@ module Homebrew def initialize(argv:) super @argv = argv + @cmdline_args = argv @args_parsed = false @processed_options = [] end @@ -166,6 +167,12 @@ module Homebrew formulae.any? { |args_f| args_f.full_name == f.full_name } end + def build_from_source + return true if args_parsed && (build_from_source? || s?) + + cmdline_args.include?("--build-from-source") || cmdline_args.include?("-s") + end + private def downcased_unique_named @@ -208,12 +215,6 @@ module Homebrew cmdline_args.include?("--build-bottle") end - def build_from_source - return true if args_parsed && (build_from_source? || s?) - - cmdline_args.include?("--build-from-source") || cmdline_args.include?("-s") - end - def spec(default = :stable) if head :head diff --git a/Library/Homebrew/cli/parser.rb b/Library/Homebrew/cli/parser.rb index e3e59de199..07d05246f2 100644 --- a/Library/Homebrew/cli/parser.rb +++ b/Library/Homebrew/cli/parser.rb @@ -259,7 +259,7 @@ module Homebrew end def option_passed?(name) - @args.respond_to?(name) || @args.respond_to?("#{name}?") + @args[name.to_sym] || @args["#{name}?".to_sym] end def wrap_option_desc(desc) diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index bd8f745f03..78003daf96 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -86,7 +86,7 @@ module Homebrew end def args - @args ||= CLI::Args.new(argv: ARGV) + @args ||= CLI::Args.new(argv: ARGV_WITHOUT_MONKEY_PATCHING) end def messages