Merge pull request #6432 from GauthamGoli/argv-cleanup-2
argv: move flags_only to cli/args
This commit is contained in:
		
						commit
						4a3442d1a4
					
				@ -28,6 +28,14 @@ module Homebrew
 | 
				
			|||||||
            .map(&method(:to_cli_option))
 | 
					            .map(&method(:to_cli_option))
 | 
				
			||||||
            .select { |arg| arg.start_with?("-") }
 | 
					            .select { |arg| arg.start_with?("-") }
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      def flags_only
 | 
				
			||||||
 | 
					        to_h.keys
 | 
				
			||||||
 | 
					            .map(&:to_s)
 | 
				
			||||||
 | 
					            .reject { |name| %w[argv remaining].include?(name) }
 | 
				
			||||||
 | 
					            .map(&method(:to_cli_option))
 | 
				
			||||||
 | 
					            .select { |arg| arg.start_with?("--") }
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
				
			|||||||
@ -162,7 +162,7 @@ module Homebrew
 | 
				
			|||||||
      tab = Tab.for_keg(keg)
 | 
					      tab = Tab.for_keg(keg)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    build_options = BuildOptions.new(Options.create(ARGV.flags_only), f.options)
 | 
					    build_options = BuildOptions.new(Options.create(Homebrew.args.flags_only), f.options)
 | 
				
			||||||
    options = build_options.used_options
 | 
					    options = build_options.used_options
 | 
				
			||||||
    options |= f.build.used_options
 | 
					    options |= f.build.used_options
 | 
				
			||||||
    options &= f.options
 | 
					    options &= f.options
 | 
				
			||||||
 | 
				
			|||||||
@ -16,7 +16,7 @@ module Homebrew
 | 
				
			|||||||
      backup keg
 | 
					      backup keg
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    build_options = BuildOptions.new(Options.create(ARGV.flags_only), f.options)
 | 
					    build_options = BuildOptions.new(Options.create(Homebrew.args.flags_only), f.options)
 | 
				
			||||||
    options = build_options.used_options
 | 
					    options = build_options.used_options
 | 
				
			||||||
    options |= f.build.used_options
 | 
					    options |= f.build.used_options
 | 
				
			||||||
    options &= f.options
 | 
					    options &= f.options
 | 
				
			||||||
 | 
				
			|||||||
@ -225,5 +225,10 @@ describe Homebrew::CLI::Parser do
 | 
				
			|||||||
      parser.parse(["--foo", "-vds", "a", "b", "cdefg"])
 | 
					      parser.parse(["--foo", "-vds", "a", "b", "cdefg"])
 | 
				
			||||||
      expect(Homebrew.args.options_only).to eq %w[--foo -v -d -s]
 | 
					      expect(Homebrew.args.options_only).to eq %w[--foo -v -d -s]
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    it "#flags_only" do
 | 
				
			||||||
 | 
					      parser.parse(["--foo", "-vds", "a", "b", "cdefg"])
 | 
				
			||||||
 | 
					      expect(Homebrew.args.flags_only).to eq %w[--foo]
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user