cli/parser: Don't treat args with --cask
as formulae
- For the command `brew install --cask racket`, a user was reporting the behaviour where despite `--cask` in the command, they were getting output about the `racket` formula having been renamed: ``` $ brew install --cask racket Warning: Use minimal-racket instead of deprecated racket ==> Downloading https://mirror.racket-lang.org/installers/8.7/racket-8.7-x86_64-macosx-cs. ==> Installing Cask racket [...] racket was successfully installed! ``` - The "instead of deprecated ..." messaging comes from the `TapLoader` class `formula_name_path` method, so _something_ must be assuming that everything is initially a formula before _later_ learning from further args parsing that there's a `--cask` qualifier to scope to only casks. - There are always `@formula_options` and args parsing is recursive, going through each option, so we check that the original `argv` items include a `--cask` and skip calling the `formulae` method if that's the case. - After this change, the "formula renames" words no longer show up. ``` $ brew install --cask racket ==> Downloading https://mirror.racket-lang.org/installers/8.7/racket-8.7-aarch64-macosx-cs.dmg ==> Installing Cask racket [...] racket was successfully installed! ```
This commit is contained in:
parent
10845a1122
commit
8881ea74b5
@ -298,9 +298,10 @@ module Homebrew
|
|||||||
def parse(argv = ARGV.freeze, ignore_invalid_options: false)
|
def parse(argv = ARGV.freeze, ignore_invalid_options: false)
|
||||||
raise "Arguments were already parsed!" if @args_parsed
|
raise "Arguments were already parsed!" if @args_parsed
|
||||||
|
|
||||||
# If we accept formula options, parse once allowing invalid options
|
# If we accept formula options, but the command isn't scoped only
|
||||||
# so we can get the remaining list containing formula names.
|
# to casks, parse once allowing invalid options so we can get the
|
||||||
if @formula_options
|
# remaining list containing formula names.
|
||||||
|
if @formula_options && argv.exclude?("--cask")
|
||||||
remaining, non_options = parse_remaining(argv, ignore_invalid_options: true)
|
remaining, non_options = parse_remaining(argv, ignore_invalid_options: true)
|
||||||
|
|
||||||
argv = [*remaining, "--", *non_options]
|
argv = [*remaining, "--", *non_options]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user