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

argv: move flags_only to cli/args #6432

Merged
merged 1 commit into from Sep 9, 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
8 changes: 8 additions & 0 deletions Library/Homebrew/cli/args.rb
Expand Up @@ -28,6 +28,14 @@ def options_only
.map(&method(:to_cli_option))
.select { |arg| arg.start_with?("-") }
end

def flags_only
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meant to comment on this before: can the ARGV.flags_only method be removed entirely now? If so and if it has no usage in Homebrew/homebrew-core: please remove it. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is being used in build.rb and software_spec.rb
Do we leave software_spec.rb too towards the end ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeh, sounds good. Could you add a comment or similar (can be in another PR) in various places to make clear 1) that function shouldn't be used elsewhere and 2) just any brain dumping based on your current investigations?

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/cmd/upgrade.rb
Expand Up @@ -162,7 +162,7 @@ def upgrade_formula(f)
tab = Tab.for_keg(keg)
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 |= f.build.used_options
options &= f.options
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/reinstall.rb
Expand Up @@ -16,7 +16,7 @@ def reinstall_formula(f, build_from_source: false)
backup keg
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 |= f.build.used_options
options &= f.options
Expand Down
5 changes: 5 additions & 0 deletions Library/Homebrew/test/cli/parser_spec.rb
Expand Up @@ -225,5 +225,10 @@
parser.parse(["--foo", "-vds", "a", "b", "cdefg"])
expect(Homebrew.args.options_only).to eq %w[--foo -v -d -s]
end

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