Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "argv: move options_only to cli/args" #6451

Merged
merged 1 commit into from Sep 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 0 additions & 16 deletions Library/Homebrew/cli/args.rb
Expand Up @@ -12,22 +12,6 @@ def initialize(argv:)
super
@argv = argv
end

def to_cli_option(name)
if name.length == 2
"-#{name.tr("?", "")}"
else
"--#{name.tr("_", "-").tr("?", "")}"
end
end

def options_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
2 changes: 1 addition & 1 deletion Library/Homebrew/cli/parser.rb
Expand Up @@ -10,7 +10,7 @@
module Homebrew
module CLI
class Parser
attr_reader :processed_options, :hide_from_man_page, :args
attr_reader :processed_options, :hide_from_man_page

def self.parse(args = ARGV, &block)
new(&block).parse(args)
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cmd/cat.rb
Expand Up @@ -25,6 +25,6 @@ def cat
raise "`brew cat` doesn't support multiple arguments" if args.remaining.size > 1

cd HOMEBREW_REPOSITORY
safe_system "cat", formulae.first.path, *Homebrew.args.options_only
safe_system "cat", formulae.first.path, *ARGV.options_only
end
end
2 changes: 1 addition & 1 deletion Library/Homebrew/cmd/list.rb
Expand Up @@ -70,7 +70,7 @@ def list
puts Formatter.columns(full_names)
else
ENV["CLICOLOR"] = nil
safe_system "ls", *Homebrew.args.options_only << HOMEBREW_CELLAR
safe_system "ls", *ARGV.options_only << HOMEBREW_CELLAR
end
elsif args.verbose? || !$stdout.tty?
system_command! "find", args: ARGV.kegs.map(&:to_s) + %w[-not -type d -print], print_stdout: true
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cmd/log.rb
Expand Up @@ -57,7 +57,7 @@ def git_log(cd_dir, path = nil, tap = nil)
git -C "#{git_cd}" fetch --unshallow
EOS
end
args = Homebrew.args.options_only
args = ARGV.options_only
args += ["--follow", "--", path] unless path.nil?
system "git", "log", *args
end
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/dev-cmd/test.rb
Expand Up @@ -82,7 +82,7 @@ def test
--
#{HOMEBREW_LIBRARY_PATH}/test.rb
#{f.path}
].concat(Homebrew.args.options_only)
].concat(ARGV.options_only)

if f.head?
args << "--HEAD"
Expand Down
16 changes: 0 additions & 16 deletions Library/Homebrew/test/cli/parser_spec.rb
Expand Up @@ -210,20 +210,4 @@
expect { parser.parse(["--switch-b"]) }.to raise_error(RuntimeError, /Arguments were already parsed!/)
end
end

describe "test argv extensions" do
subject(:parser) {
described_class.new do
switch "--foo"
switch "-v"
switch "-d"
switch "-s"
end
}

it "#options_only" do
parser.parse(["--foo", "-vds", "a", "b", "cdefg"])
expect(Homebrew.args.options_only).to eq %w[--foo -v -d -s]
end
end
end