From 2ee30b8067128db2e07a12c786873262019402de Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 28 Sep 2020 01:24:55 +0200 Subject: [PATCH 01/11] Refactor `MinNamedArgumentsError` and `MaxNamedArgumentsError`. --- Library/Homebrew/cli/parser.rb | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/Library/Homebrew/cli/parser.rb b/Library/Homebrew/cli/parser.rb index be94c98aa0..d1ee78f854 100644 --- a/Library/Homebrew/cli/parser.rb +++ b/Library/Homebrew/cli/parser.rb @@ -454,29 +454,18 @@ module Homebrew class MaxNamedArgumentsError < UsageError def initialize(maximum) - message = case maximum + super case maximum when 0 - "this command does not take named arguments" - when 1 - "this command does not take multiple named arguments" + "This command does not take named arguments." else - "this command does not take more than #{maximum} named arguments" + "This command does not take more than #{maximum} named #{"argument".pluralize(maximum)}" end - super message end end class MinNamedArgumentsError < UsageError def initialize(minimum) - message = case minimum - when 1 - "this command requires a named argument" - when 2 - "this command requires multiple named arguments" - else - "this command requires at least #{minimum} named arguments" - end - super message + super "This command requires at least #{minimum} named #{"argument".pluralize(minimum)}." end end end From 67519d487a49b9a589091e8685a252f6d0c3e60e Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 28 Sep 2020 01:31:47 +0200 Subject: [PATCH 02/11] Include `cask` in `brew install` help text. --- Library/Homebrew/cmd/install.rb | 11 ++++++----- docs/Manpage.md | 9 +++++---- manpages/brew.1 | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index 2782b4d7df..a995f745e5 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -109,12 +109,13 @@ module Homebrew Homebrew::CLI::Parser.new do usage_banner <<~EOS - `install` [] + `install` [] | - Install . Additional options specific to may be appended to the command. + Install a or . Additional options specific to a may be + appended to the command. - Unless `HOMEBREW_NO_INSTALL_CLEANUP` is set, `brew cleanup` will then be run for the - installed formulae or, every 30 days, for all formulae. + Unless `HOMEBREW_NO_INSTALL_CLEANUP` is set, `brew cleanup` will then be run for + the installed formulae or, every 30 days, for all formulae. EOS switch "-d", "--debug", description: "If brewing fails, open an interactive debugging session with access to IRB "\ @@ -139,7 +140,7 @@ module Homebrew end formula_options - min_named :formula + min_named 1 end end diff --git a/docs/Manpage.md b/docs/Manpage.md index 92fe5a90fd..94d6df25b8 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -304,12 +304,13 @@ If *`formula`* is provided, show summary of information about *`formula`*. * `-v`, `--verbose`: Show more verbose analytics data for *`formula`*. -### `install` [*`options`*] *`formula`* +### `install` [*`options`*] *`formula`*|*`cask`* -Install *`formula`*. Additional options specific to *`formula`* may be appended to the command. +Install a *`formula`* or *`cask`*. Additional options specific to a *`formula`* may be +appended to the command. -Unless `HOMEBREW_NO_INSTALL_CLEANUP` is set, `brew cleanup` will then be run for the -installed formulae or, every 30 days, for all formulae. +Unless `HOMEBREW_NO_INSTALL_CLEANUP` is set, `brew cleanup` will then be run for +the installed formulae or, every 30 days, for all formulae. * `-d`, `--debug`: If brewing fails, open an interactive debugging session with access to IRB or a shell inside the temporary build directory. diff --git a/manpages/brew.1 b/manpages/brew.1 index 2140c06953..4ccb2bd5ed 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -445,8 +445,8 @@ Print JSON of all available formulae\. \fB\-v\fR, \fB\-\-verbose\fR Show more verbose analytics data for \fIformula\fR\. . -.SS "\fBinstall\fR [\fIoptions\fR] \fIformula\fR" -Install \fIformula\fR\. Additional options specific to \fIformula\fR may be appended to the command\. +.SS "\fBinstall\fR [\fIoptions\fR] \fIformula\fR|\fIcask\fR" +Install a \fIformula\fR or \fIcask\fR\. Additional options specific to a \fIformula\fR may be appended to the command\. . .P Unless \fBHOMEBREW_NO_INSTALL_CLEANUP\fR is set, \fBbrew cleanup\fR will then be run for the installed formulae or, every 30 days, for all formulae\. From d443d9ab75047bdbefa51ca2db6d7fcfe786f59d Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 28 Sep 2020 01:33:29 +0200 Subject: [PATCH 03/11] Include `cask` in `brew reinstall` help text. --- Library/Homebrew/cmd/reinstall.rb | 8 ++++---- docs/Manpage.md | 6 +++--- manpages/brew.1 | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Library/Homebrew/cmd/reinstall.rb b/Library/Homebrew/cmd/reinstall.rb index e19f67a5d6..fbafbccf57 100644 --- a/Library/Homebrew/cmd/reinstall.rb +++ b/Library/Homebrew/cmd/reinstall.rb @@ -18,10 +18,10 @@ module Homebrew def reinstall_args Homebrew::CLI::Parser.new do usage_banner <<~EOS - `reinstall` [] + `reinstall` [] | - Uninstall and then install using the same options it was originally - installed with, plus any appended brew formula options. + Uninstall and then reinstall a or using the same options it was + originally installed with, plus any appended options specific to a . Unless `HOMEBREW_NO_INSTALL_CLEANUP` is set, `brew cleanup` will then be run for the reinstalled formulae or, every 30 days, for all formulae. @@ -50,7 +50,7 @@ module Homebrew description: "Print install times for each formula at the end of the run." conflicts "--build-from-source", "--force-bottle" formula_options - min_named :formula + min_named 1 end end diff --git a/docs/Manpage.md b/docs/Manpage.md index 94d6df25b8..7018ba68a2 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -524,10 +524,10 @@ all items or checking if any current formulae/casks have Ruby issues. * `--syntax`: Syntax-check all of Homebrew's Ruby files (if no `*`tap`*` is passed). -### `reinstall` [*`options`*] *`formula`* +### `reinstall` [*`options`*] *`formula`*|*`cask`* -Uninstall and then install *`formula`* using the same options it was originally -installed with, plus any appended brew formula options. +Uninstall and then reinstall a *`formula`* or *`cask`* using the same options it was +originally installed with, plus any appended options specific to a *`formula`*. Unless `HOMEBREW_NO_INSTALL_CLEANUP` is set, `brew cleanup` will then be run for the reinstalled formulae or, every 30 days, for all formulae. diff --git a/manpages/brew.1 b/manpages/brew.1 index 4ccb2bd5ed..cde4acbc8a 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -779,8 +779,8 @@ Verify any alias symlinks in each tap\. \fB\-\-syntax\fR Syntax\-check all of Homebrew\'s Ruby files (if no \fB\fR is passed)\. . -.SS "\fBreinstall\fR [\fIoptions\fR] \fIformula\fR" -Uninstall and then install \fIformula\fR using the same options it was originally installed with, plus any appended brew formula options\. +.SS "\fBreinstall\fR [\fIoptions\fR] \fIformula\fR|\fIcask\fR" +Uninstall and then reinstall a \fIformula\fR or \fIcask\fR using the same options it was originally installed with, plus any appended options specific to a \fIformula\fR\. . .P Unless \fBHOMEBREW_NO_INSTALL_CLEANUP\fR is set, \fBbrew cleanup\fR will then be run for the reinstalled formulae or, every 30 days, for all formulae\. From 16d5596fbdbebccfd18fe94fa8c8c72f6823cf46 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 28 Sep 2020 02:31:11 +0200 Subject: [PATCH 04/11] Fix code style. --- Library/Homebrew/cmd/install.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index a995f745e5..e4bd2a31ab 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -74,15 +74,18 @@ module Homebrew [:switch, "--HEAD", { description: "If defines it, install the HEAD version, aka. master, trunk, unstable.", - }], [:switch, "--fetch-HEAD", { + }], + [:switch, "--fetch-HEAD", { description: "Fetch the upstream repository to detect if the HEAD installation of the "\ "formula is outdated. Otherwise, the repository's HEAD will only be checked for "\ "updates when a new stable or development version has been released.", - }], [:switch, "--keep-tmp", { + }], + [:switch, "--keep-tmp", { description: "Retain the temporary files created during installation.", - }], [:switch, "--build-bottle", { + }], + [:switch, "--build-bottle", { description: "Prepare the formula for eventual bottling during installation, skipping any "\ "post-install steps.", @@ -104,7 +107,7 @@ module Homebrew }], [:switch, "-g", "--git", { description: "Create a Git repository, useful for creating patches to the software.", - }] + }], ] Homebrew::CLI::Parser.new do From e40eece17bdf83b6d93fc8fff36f94938db22cd3 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 28 Sep 2020 02:10:17 +0200 Subject: [PATCH 05/11] Add cask options to `brew reinstall`. --- Library/Homebrew/cli/named_args.rb | 65 +++++++++------------ Library/Homebrew/cmd/reinstall.rb | 91 +++++++++++++++++++++--------- 2 files changed, 91 insertions(+), 65 deletions(-) diff --git a/Library/Homebrew/cli/named_args.rb b/Library/Homebrew/cli/named_args.rb index e82c911175..e5a2342b8b 100644 --- a/Library/Homebrew/cli/named_args.rb +++ b/Library/Homebrew/cli/named_args.rb @@ -23,21 +23,33 @@ module Homebrew super(@args) end + def to_casks + @to_casks ||= to_formulae_and_casks(only: :cask).freeze + end + def to_formulae @to_formulae ||= to_formulae_and_casks(only: :formula).freeze end - def to_formulae_and_casks(only: nil) + def to_formulae_and_casks(only: nil, method: nil) @to_formulae_and_casks ||= {} @to_formulae_and_casks[only] ||= begin - to_objects(only: only).reject { |o| o.is_a?(Tap) }.freeze + to_objects(only: only, method: method).reject { |o| o.is_a?(Tap) }.freeze end end - def load_formula_or_cask(name, only: nil) + def load_formula_or_cask(name, only: nil, method: nil) if only != :cask begin - formula = Formulary.factory(name, spec, force_bottle: @force_bottle, flags: @flags) + formula = case method + when nil, :factory + Formulary.factory(name, *spec, force_bottle: @force_bottle, flags: @flags) + when :resolve + Formulary.resolve(name, spec: spec, force_bottle: @force_bottle, flags: @flags) + else + raise + end + warn_if_cask_conflicts(name, "formula") unless only == :formula return formula rescue FormulaUnavailableError => e @@ -47,7 +59,7 @@ module Homebrew if only != :formula begin - return Cask::CaskLoader.load(name) + return Cask::CaskLoader.load(name, config: Cask::Config.from_args(@parent)) rescue Cask::CaskUnavailableError raise e if only == :cask end @@ -58,46 +70,30 @@ module Homebrew private :load_formula_or_cask def resolve_formula(name) - Formulary.resolve(name, spec: spec(nil), force_bottle: @force_bottle, flags: @flags) + Formulary.resolve(name, spec: spec, force_bottle: @force_bottle, flags: @flags) end private :resolve_formula def to_resolved_formulae - @to_resolved_formulae ||= (downcased_unique_named - homebrew_tap_cask_names).map do |name| - resolve_formula(name) - end.uniq(&:name).freeze + @to_resolved_formulae ||= to_formulae_and_casks(only: :formula, method: :resolve) + .freeze end def to_resolved_formulae_to_casks - @to_resolved_formulae_to_casks ||= begin - resolved_formulae = [] - casks = [] - - downcased_unique_named.each do |name| - resolved_formulae << resolve_formula(name) - - warn_if_cask_conflicts(name, "formula") - rescue FormulaUnavailableError - begin - casks << Cask::CaskLoader.load(name) - rescue Cask::CaskUnavailableError - raise "No available formula or cask with the name \"#{name}\"" - end - end - - [resolved_formulae.freeze, casks.freeze].freeze - end + @to_resolved_formulae_to_casks ||= to_formulae_and_casks(method: :resolve) + .partition { |o| o.is_a?(Formula) } + .map(&:freeze).freeze end # Convert named arguments to `Tap`, `Formula` or `Cask` objects. # If both a formula and cask exist with the same name, returns the # formula and prints a warning unless `only` is specified. - def to_objects(only: nil) + def to_objects(only: nil, method: nil) @to_objects ||= {} @to_objects[only] ||= downcased_unique_named.flat_map do |name| next Tap.fetch(name) if only == :tap || (only.nil? && name.count("/") == 1 && !name.start_with?("./", "/")) - load_formula_or_cask(name, only: only) + load_formula_or_cask(name, only: only, method: method) end.uniq.freeze end @@ -132,12 +128,6 @@ module Homebrew end.uniq.freeze end - def to_casks - @to_casks ||= downcased_unique_named - .map { |name| Cask::CaskLoader.load(name, config: Cask::Config.from_args(@parent)) } - .freeze - end - def to_kegs @to_kegs ||= downcased_unique_named.map do |name| resolve_keg name @@ -187,9 +177,10 @@ module Homebrew end.uniq end - def spec(default = :stable) - @override_spec || default + def spec + @override_spec end + private :spec def resolve_keg(name) raise UsageError if name.blank? diff --git a/Library/Homebrew/cmd/reinstall.rb b/Library/Homebrew/cmd/reinstall.rb index fbafbccf57..4aa8b0be3f 100644 --- a/Library/Homebrew/cmd/reinstall.rb +++ b/Library/Homebrew/cmd/reinstall.rb @@ -16,6 +16,39 @@ module Homebrew module_function def reinstall_args + cask_only_options = [ + [:switch, "--cask", "--casks", { + description: "Treat all named arguments as casks.", + }], + *Cask::Cmd::OPTIONS, + *Cask::Cmd::AbstractCommand::OPTIONS, + ] + + formula_only_options = [ + [:switch, "--formula", "--formulae", { + description: "Treat all named arguments as formulae.", + }], + [:switch, "-s", "--build-from-source", { + description: "Compile from source even if a bottle is available.", + }], + [:switch, "-i", "--interactive", { + description: "Download and patch , then open a shell. This allows the user to "\ + "run `./configure --help` and otherwise determine how to turn the software "\ + "package into a Homebrew package.", + }], + [:switch, "--force-bottle", { + description: "Install from a bottle if it exists for the current or newest version of "\ + "macOS, even if it would not normally be used for installation.", + }], + [:switch, "--keep-tmp", { + description: "Retain the temporary files created during installation.", + }], + [:switch, "--display-times", { + env: :display_install_times, + description: "Print install times for each formula at the end of the run.", + }], + ] + Homebrew::CLI::Parser.new do usage_banner <<~EOS `reinstall` [] | @@ -29,26 +62,23 @@ module Homebrew switch "-d", "--debug", description: "If brewing fails, open an interactive debugging session with access to IRB "\ "or a shell inside the temporary build directory." - switch "-s", "--build-from-source", - description: "Compile from source even if a bottle is available." - switch "-i", "--interactive", - description: "Download and patch , then open a shell. This allows the user to "\ - "run `./configure --help` and otherwise determine how to turn the software "\ - "package into a Homebrew package." - switch "--force-bottle", - description: "Install from a bottle if it exists for the current or newest version of "\ - "macOS, even if it would not normally be used for installation." - switch "--keep-tmp", - description: "Retain the temporary files created during installation." switch "-f", "--force", description: "Install without checking for previously installed keg-only or "\ "non-migrated versions." switch "-v", "--verbose", description: "Print the verification and postinstall steps." - switch "--display-times", - env: :display_install_times, - description: "Print install times for each formula at the end of the run." conflicts "--build-from-source", "--force-bottle" + + formula_only_options.each do |options| + send(*options) + conflicts "--cask", options[-2] + end + + cask_only_options.each do |options| + send(*options) + conflicts "--formula", options[-2] + end + formula_options min_named 1 end @@ -61,8 +91,13 @@ module Homebrew Install.perform_preinstall_checks - resolved_formulae, casks = args.named.to_resolved_formulae_to_casks - resolved_formulae.each do |f| + only = :cask if args.cask? && !args.formula? + only = :formula if !args.cask? && args.formula? + + formulae, casks = args.named.to_formulae_and_casks(only: only, method: :resolve) + .partition { |o| o.is_a?(Formula) } + + formulae.each do |f| if f.pinned? onoe "#{f.full_name} is pinned. You must unpin it to reinstall." next @@ -74,18 +109,18 @@ module Homebrew Upgrade.check_installed_dependents(args: args) + if casks.any? + Cask::Cmd::Reinstall.reinstall_casks( + *casks, + binaries: EnvConfig.cask_opts_binaries?, + verbose: args.verbose?, + force: args.force?, + require_sha: EnvConfig.cask_opts_require_sha?, + skip_cask_deps: args.skip_cask_deps?, + quarantine: EnvConfig.cask_opts_quarantine?, + ) + end + Homebrew.messages.display_messages(display_times: args.display_times?) - - return if casks.blank? - - Cask::Cmd::Reinstall.reinstall_casks( - *casks, - binaries: EnvConfig.cask_opts_binaries?, - verbose: args.verbose?, - force: args.force?, - require_sha: EnvConfig.cask_opts_require_sha?, - skip_cask_deps: args.skip_cask_deps?, - quarantine: EnvConfig.cask_opts_quarantine?, - ) end end From 994e95e35645270a80b096b5f932c938d08f41e3 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 28 Sep 2020 02:17:31 +0200 Subject: [PATCH 06/11] Refactor usage of `NamedArgs` in `brew install`. --- Library/Homebrew/cli/named_args.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/Library/Homebrew/cli/named_args.rb b/Library/Homebrew/cli/named_args.rb index e5a2342b8b..ce9e8ea8f2 100644 --- a/Library/Homebrew/cli/named_args.rb +++ b/Library/Homebrew/cli/named_args.rb @@ -96,6 +96,7 @@ module Homebrew load_formula_or_cask(name, only: only, method: method) end.uniq.freeze end + private :to_objects def to_formulae_paths to_paths(only: :formulae) From 7f14e55f997b70d5ff829b510928f040e59aed05 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 28 Sep 2020 02:34:14 +0200 Subject: [PATCH 07/11] Add missing cask options to `brew upgrade`. --- Library/Homebrew/cask/cmd/upgrade.rb | 17 ++- Library/Homebrew/cmd/upgrade.rb | 91 +++++++----- docs/Manpage.md | 106 ++++++++++++-- manpages/brew.1 | 202 ++++++++++++++++++++++++--- 4 files changed, 342 insertions(+), 74 deletions(-) diff --git a/Library/Homebrew/cask/cmd/upgrade.rb b/Library/Homebrew/cask/cmd/upgrade.rb index 2f0d183288..e83cb4dd39 100644 --- a/Library/Homebrew/cask/cmd/upgrade.rb +++ b/Library/Homebrew/cask/cmd/upgrade.rb @@ -13,16 +13,25 @@ module Cask "Upgrades all outdated casks or the specified casks." end + OPTIONS = [ + [:switch, "--skip-cask-deps", { + description: "Skip installing cask dependencies.", + }], + [:switch, "--greedy", { + description: "Also include casks with `auto_updates true` or `version :latest`.", + }], + ].freeze + def self.parser super do switch "--force", description: "Force overwriting existing files." - switch "--skip-cask-deps", - description: "Skip installing cask dependencies." - switch "--greedy", - description: "Also include casks which specify `auto_updates true` or `version :latest`." switch "--dry-run", description: "Show what would be upgraded, but do not actually upgrade anything." + + OPTIONS.each do |option| + send(*option) + end end end diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb index a65fd1459f..fe7b6fc2bb 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -12,6 +12,51 @@ module Homebrew module_function def upgrade_args + cask_only_options = [ + [:switch, "--cask", "--casks", { + description: "Treat all named arguments as casks. If no named arguments " \ + "are specified, upgrade only outdated casks.", + }], + *Cask::Cmd::OPTIONS, + *Cask::Cmd::AbstractCommand::OPTIONS, + *Cask::Cmd::Upgrade::OPTIONS, + ] + + formula_only_options = [ + [:switch, "--formula", "--formulae", { + description: "Treat all named arguments as formulae. If no named arguments" \ + "are specified, upgrade only outdated formulae.", + }], + [:switch, "-s", "--build-from-source", { + description: "Compile from source even if a bottle is available.", + }], + [:switch, "-i", "--interactive", { + description: "Download and patch , then open a shell. This allows the user to "\ + "run `./configure --help` and otherwise determine how to turn the software "\ + "package into a Homebrew package.", + }], + [:switch, "--force-bottle", { + description: "Install from a bottle if it exists for the current or newest version of "\ + "macOS, even if it would not normally be used for installation.", + }], + [:switch, "--fetch-HEAD", { + description: "Fetch the upstream repository to detect if the HEAD installation of the "\ + "formula is outdated. Otherwise, the repository's HEAD will only be checked for "\ + "updates when a new stable or development version has been released.", + + }], + [:switch, "--ignore-pinned", { + description: "Set a successful exit status even if pinned formulae are not upgraded.", + }], + [:switch, "--keep-tmp", { + description: "Retain the temporary files created during installation.", + }], + [:switch, "--display-times", { + env: :display_install_times, + description: "Print install times for each formula at the end of the run.", + }], + ] + Homebrew::CLI::Parser.new do usage_banner <<~EOS `upgrade` [] [|] @@ -26,46 +71,26 @@ module Homebrew switch "-d", "--debug", description: "If brewing fails, open an interactive debugging session with access to IRB "\ "or a shell inside the temporary build directory." - switch "--formula", - description: "Only upgrade outdated formulae." - switch "--cask", - description: "Only upgrade outdated casks." - switch "-s", "--build-from-source", - description: "Compile from source even if a bottle is available." - switch "-i", "--interactive", - description: "Download and patch , then open a shell. This allows the user to "\ - "run `./configure --help` and otherwise determine how to turn the software "\ - "package into a Homebrew package." - switch "--force-bottle", - description: "Install from a bottle if it exists for the current or newest version of "\ - "macOS, even if it would not normally be used for installation." - switch "--fetch-HEAD", - description: "Fetch the upstream repository to detect if the HEAD installation of the "\ - "formula is outdated. Otherwise, the repository's HEAD will only be checked for "\ - "updates when a new stable or development version has been released." - switch "--ignore-pinned", - description: "Set a successful exit status even if pinned formulae are not upgraded." - switch "--keep-tmp", - description: "Retain the temporary files created during installation." switch "-f", "--force", - description: "Install without checking for previously installed keg-only or "\ - "non-migrated versions." + description: "Install formulae without checking for previously installed keg-only or "\ + "non-migrated versions. Overwrite existing files when installing casks." switch "-v", "--verbose", description: "Print the verification and postinstall steps." - switch "--display-times", - env: :display_install_times, - description: "Print install times for each formula at the end of the run." switch "-n", "--dry-run", description: "Show what would be upgraded, but do not actually upgrade anything." - switch "--greedy", - description: "Upgrade casks with `auto_updates` or `version :latest`" + conflicts "--build-from-source", "--force-bottle" - conflicts "--formula", "--greedy" - ["--formula", "-s", "--build-from-source", "-i", "--interactive", - "--force-bottle", "--fetch-HEAD", "--ignore-pinned", "--keep-tmp", - "--display-times"].each do |flag| - conflicts "--cask", flag + + formula_only_options.each do |options| + send(*options) + conflicts "--cask", options[-2] end + + cask_only_options.each do |options| + send(*options) + conflicts "--formula", options[-2] + end + formula_options end end diff --git a/docs/Manpage.md b/docs/Manpage.md index 7018ba68a2..3298d50e85 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -534,6 +534,12 @@ reinstalled formulae or, every 30 days, for all formulae. * `-d`, `--debug`: If brewing fails, open an interactive debugging session with access to IRB or a shell inside the temporary build directory. +* `-f`, `--force`: + Install without checking for previously installed keg-only or non-migrated versions. +* `-v`, `--verbose`: + Print the verification and postinstall steps. +* `--formula`: + Treat all named arguments as formulae. * `-s`, `--build-from-source`: Compile *`formula`* from source even if a bottle is available. * `-i`, `--interactive`: @@ -542,12 +548,46 @@ reinstalled formulae or, every 30 days, for all formulae. Install from a bottle if it exists for the current or newest version of macOS, even if it would not normally be used for installation. * `--keep-tmp`: Retain the temporary files created during installation. -* `-f`, `--force`: - Install without checking for previously installed keg-only or non-migrated versions. -* `-v`, `--verbose`: - Print the verification and postinstall steps. * `--display-times`: Print install times for each formula at the end of the run. +* `--cask`: + Treat all named arguments as casks. +* `--appdir`: + Target location for Applications. Default: `/Applications` +* `--colorpickerdir`: + Target location for Color Pickers. Default: `~/Library/ColorPickers` +* `--prefpanedir`: + Target location for Preference Panes. Default: `~/Library/PreferencePanes` +* `--qlplugindir`: + Target location for QuickLook Plugins. Default: `~/Library/QuickLook` +* `--mdimporterdir`: + Target location for Spotlight Plugins. Default: `~/Library/Spotlight` +* `--dictionarydir`: + Target location for Dictionaries. Default: `~/Library/Dictionaries` +* `--fontdir`: + Target location for Fonts. Default: `~/Library/Fonts` +* `--servicedir`: + Target location for Services. Default: `~/Library/Services` +* `--input_methoddir`: + Target location for Input Methods. Default: `~/Library/Input Methods` +* `--internet_plugindir`: + Target location for Internet Plugins. Default: `~/Library/Internet Plug-Ins` +* `--audio_unit_plugindir`: + Target location for Audio Unit Plugins. Default: `~/Library/Audio/Plug-Ins/Components` +* `--vst_plugindir`: + Target location for VST Plugins. Default: `~/Library/Audio/Plug-Ins/VST` +* `--vst3_plugindir`: + Target location for VST3 Plugins. Default: `~/Library/Audio/Plug-Ins/VST3` +* `--screen_saverdir`: + Target location for Screen Savers. Default: `~/Library/Screen Savers` +* `--language`: + Set language of the Cask to install. The first matching language is used, otherwise the default language on the Cask. The default value is the `language of your system` +* `--[no-]binaries`: + Disable/enable linking of helper executables. Default: enabled +* `--require-sha`: + Require all casks to have a checksum. +* `--[no-]quarantine`: + Disable/enable quarantining of downloads. Default: enabled ### `search` [*`options`*] [*`text`*|`/`*`text`*`/`] @@ -681,10 +721,14 @@ upgraded formulae or, every 30 days, for all formulae. * `-d`, `--debug`: If brewing fails, open an interactive debugging session with access to IRB or a shell inside the temporary build directory. +* `-f`, `--force`: + Install formulae without checking for previously installed keg-only or non-migrated versions. Overwrite existing files when installing casks. +* `-v`, `--verbose`: + Print the verification and postinstall steps. +* `-n`, `--dry-run`: + Show what would be upgraded, but do not actually upgrade anything. * `--formula`: - Only upgrade outdated formulae. -* `--cask`: - Only upgrade outdated casks. + Treat all named arguments as formulae. If no named argumentsare specified, upgrade only outdated formulae. * `-s`, `--build-from-source`: Compile *`formula`* from source even if a bottle is available. * `-i`, `--interactive`: @@ -697,16 +741,50 @@ upgraded formulae or, every 30 days, for all formulae. Set a successful exit status even if pinned formulae are not upgraded. * `--keep-tmp`: Retain the temporary files created during installation. -* `-f`, `--force`: - Install without checking for previously installed keg-only or non-migrated versions. -* `-v`, `--verbose`: - Print the verification and postinstall steps. * `--display-times`: Print install times for each formula at the end of the run. -* `-n`, `--dry-run`: - Show what would be upgraded, but do not actually upgrade anything. +* `--cask`: + Treat all named arguments as casks. If no named arguments are specified, upgrade only outdated casks. +* `--appdir`: + Target location for Applications. Default: `/Applications` +* `--colorpickerdir`: + Target location for Color Pickers. Default: `~/Library/ColorPickers` +* `--prefpanedir`: + Target location for Preference Panes. Default: `~/Library/PreferencePanes` +* `--qlplugindir`: + Target location for QuickLook Plugins. Default: `~/Library/QuickLook` +* `--mdimporterdir`: + Target location for Spotlight Plugins. Default: `~/Library/Spotlight` +* `--dictionarydir`: + Target location for Dictionaries. Default: `~/Library/Dictionaries` +* `--fontdir`: + Target location for Fonts. Default: `~/Library/Fonts` +* `--servicedir`: + Target location for Services. Default: `~/Library/Services` +* `--input_methoddir`: + Target location for Input Methods. Default: `~/Library/Input Methods` +* `--internet_plugindir`: + Target location for Internet Plugins. Default: `~/Library/Internet Plug-Ins` +* `--audio_unit_plugindir`: + Target location for Audio Unit Plugins. Default: `~/Library/Audio/Plug-Ins/Components` +* `--vst_plugindir`: + Target location for VST Plugins. Default: `~/Library/Audio/Plug-Ins/VST` +* `--vst3_plugindir`: + Target location for VST3 Plugins. Default: `~/Library/Audio/Plug-Ins/VST3` +* `--screen_saverdir`: + Target location for Screen Savers. Default: `~/Library/Screen Savers` +* `--language`: + Set language of the Cask to install. The first matching language is used, otherwise the default language on the Cask. The default value is the `language of your system` +* `--[no-]binaries`: + Disable/enable linking of helper executables. Default: enabled +* `--require-sha`: + Require all casks to have a checksum. +* `--[no-]quarantine`: + Disable/enable quarantining of downloads. Default: enabled +* `--skip-cask-deps`: + Skip installing cask dependencies. * `--greedy`: - Upgrade casks with `auto_updates` or `version :latest` + Also include casks with `auto_updates true` or `version :latest`. ### `uses` [*`options`*] *`formula`* diff --git a/manpages/brew.1 b/manpages/brew.1 index cde4acbc8a..ec67fdec6e 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -790,6 +790,18 @@ Unless \fBHOMEBREW_NO_INSTALL_CLEANUP\fR is set, \fBbrew cleanup\fR will then be If brewing fails, open an interactive debugging session with access to IRB or a shell inside the temporary build directory\. . .TP +\fB\-f\fR, \fB\-\-force\fR +Install without checking for previously installed keg\-only or non\-migrated versions\. +. +.TP +\fB\-v\fR, \fB\-\-verbose\fR +Print the verification and postinstall steps\. +. +.TP +\fB\-\-formula\fR +Treat all named arguments as formulae\. +. +.TP \fB\-s\fR, \fB\-\-build\-from\-source\fR Compile \fIformula\fR from source even if a bottle is available\. . @@ -806,17 +818,85 @@ Install from a bottle if it exists for the current or newest version of macOS, e Retain the temporary files created during installation\. . .TP -\fB\-f\fR, \fB\-\-force\fR -Install without checking for previously installed keg\-only or non\-migrated versions\. -. -.TP -\fB\-v\fR, \fB\-\-verbose\fR -Print the verification and postinstall steps\. -. -.TP \fB\-\-display\-times\fR Print install times for each formula at the end of the run\. . +.TP +\fB\-\-cask\fR +Treat all named arguments as casks\. +. +.TP +\fB\-\-appdir\fR +Target location for Applications\. Default: \fB/Applications\fR +. +.TP +\fB\-\-colorpickerdir\fR +Target location for Color Pickers\. Default: \fB~/Library/ColorPickers\fR +. +.TP +\fB\-\-prefpanedir\fR +Target location for Preference Panes\. Default: \fB~/Library/PreferencePanes\fR +. +.TP +\fB\-\-qlplugindir\fR +Target location for QuickLook Plugins\. Default: \fB~/Library/QuickLook\fR +. +.TP +\fB\-\-mdimporterdir\fR +Target location for Spotlight Plugins\. Default: \fB~/Library/Spotlight\fR +. +.TP +\fB\-\-dictionarydir\fR +Target location for Dictionaries\. Default: \fB~/Library/Dictionaries\fR +. +.TP +\fB\-\-fontdir\fR +Target location for Fonts\. Default: \fB~/Library/Fonts\fR +. +.TP +\fB\-\-servicedir\fR +Target location for Services\. Default: \fB~/Library/Services\fR +. +.TP +\fB\-\-input_methoddir\fR +Target location for Input Methods\. Default: \fB~/Library/Input Methods\fR +. +.TP +\fB\-\-internet_plugindir\fR +Target location for Internet Plugins\. Default: \fB~/Library/Internet Plug\-Ins\fR +. +.TP +\fB\-\-audio_unit_plugindir\fR +Target location for Audio Unit Plugins\. Default: \fB~/Library/Audio/Plug\-Ins/Components\fR +. +.TP +\fB\-\-vst_plugindir\fR +Target location for VST Plugins\. Default: \fB~/Library/Audio/Plug\-Ins/VST\fR +. +.TP +\fB\-\-vst3_plugindir\fR +Target location for VST3 Plugins\. Default: \fB~/Library/Audio/Plug\-Ins/VST3\fR +. +.TP +\fB\-\-screen_saverdir\fR +Target location for Screen Savers\. Default: \fB~/Library/Screen Savers\fR +. +.TP +\fB\-\-language\fR +Set language of the Cask to install\. The first matching language is used, otherwise the default language on the Cask\. The default value is the \fBlanguage of your system\fR +. +.TP +\fB\-\-[no\-]binaries\fR +Disable/enable linking of helper executables\. Default: enabled +. +.TP +\fB\-\-require\-sha\fR +Require all casks to have a checksum\. +. +.TP +\fB\-\-[no\-]quarantine\fR +Disable/enable quarantining of downloads\. Default: enabled +. .SS "\fBsearch\fR [\fIoptions\fR] [\fItext\fR|\fB/\fR\fItext\fR\fB/\fR]" Perform a substring search of cask tokens and formula names for \fItext\fR\. If \fItext\fR is flanked by slashes, it is interpreted as a regular expression\. The search for \fItext\fR is extended online to \fBhomebrew/core\fR and \fBhomebrew/cask\fR\. . @@ -970,12 +1050,20 @@ Unless \fBHOMEBREW_NO_INSTALL_CLEANUP\fR is set, \fBbrew cleanup\fR will then be If brewing fails, open an interactive debugging session with access to IRB or a shell inside the temporary build directory\. . .TP -\fB\-\-formula\fR -Only upgrade outdated formulae\. +\fB\-f\fR, \fB\-\-force\fR +Install formulae without checking for previously installed keg\-only or non\-migrated versions\. Overwrite existing files when installing casks\. . .TP -\fB\-\-cask\fR -Only upgrade outdated casks\. +\fB\-v\fR, \fB\-\-verbose\fR +Print the verification and postinstall steps\. +. +.TP +\fB\-n\fR, \fB\-\-dry\-run\fR +Show what would be upgraded, but do not actually upgrade anything\. +. +.TP +\fB\-\-formula\fR +Treat all named arguments as formulae\. If no named argumentsare specified, upgrade only outdated formulae\. . .TP \fB\-s\fR, \fB\-\-build\-from\-source\fR @@ -1002,24 +1090,92 @@ Set a successful exit status even if pinned formulae are not upgraded\. Retain the temporary files created during installation\. . .TP -\fB\-f\fR, \fB\-\-force\fR -Install without checking for previously installed keg\-only or non\-migrated versions\. -. -.TP -\fB\-v\fR, \fB\-\-verbose\fR -Print the verification and postinstall steps\. -. -.TP \fB\-\-display\-times\fR Print install times for each formula at the end of the run\. . .TP -\fB\-n\fR, \fB\-\-dry\-run\fR -Show what would be upgraded, but do not actually upgrade anything\. +\fB\-\-cask\fR +Treat all named arguments as casks\. If no named arguments are specified, upgrade only outdated casks\. +. +.TP +\fB\-\-appdir\fR +Target location for Applications\. Default: \fB/Applications\fR +. +.TP +\fB\-\-colorpickerdir\fR +Target location for Color Pickers\. Default: \fB~/Library/ColorPickers\fR +. +.TP +\fB\-\-prefpanedir\fR +Target location for Preference Panes\. Default: \fB~/Library/PreferencePanes\fR +. +.TP +\fB\-\-qlplugindir\fR +Target location for QuickLook Plugins\. Default: \fB~/Library/QuickLook\fR +. +.TP +\fB\-\-mdimporterdir\fR +Target location for Spotlight Plugins\. Default: \fB~/Library/Spotlight\fR +. +.TP +\fB\-\-dictionarydir\fR +Target location for Dictionaries\. Default: \fB~/Library/Dictionaries\fR +. +.TP +\fB\-\-fontdir\fR +Target location for Fonts\. Default: \fB~/Library/Fonts\fR +. +.TP +\fB\-\-servicedir\fR +Target location for Services\. Default: \fB~/Library/Services\fR +. +.TP +\fB\-\-input_methoddir\fR +Target location for Input Methods\. Default: \fB~/Library/Input Methods\fR +. +.TP +\fB\-\-internet_plugindir\fR +Target location for Internet Plugins\. Default: \fB~/Library/Internet Plug\-Ins\fR +. +.TP +\fB\-\-audio_unit_plugindir\fR +Target location for Audio Unit Plugins\. Default: \fB~/Library/Audio/Plug\-Ins/Components\fR +. +.TP +\fB\-\-vst_plugindir\fR +Target location for VST Plugins\. Default: \fB~/Library/Audio/Plug\-Ins/VST\fR +. +.TP +\fB\-\-vst3_plugindir\fR +Target location for VST3 Plugins\. Default: \fB~/Library/Audio/Plug\-Ins/VST3\fR +. +.TP +\fB\-\-screen_saverdir\fR +Target location for Screen Savers\. Default: \fB~/Library/Screen Savers\fR +. +.TP +\fB\-\-language\fR +Set language of the Cask to install\. The first matching language is used, otherwise the default language on the Cask\. The default value is the \fBlanguage of your system\fR +. +.TP +\fB\-\-[no\-]binaries\fR +Disable/enable linking of helper executables\. Default: enabled +. +.TP +\fB\-\-require\-sha\fR +Require all casks to have a checksum\. +. +.TP +\fB\-\-[no\-]quarantine\fR +Disable/enable quarantining of downloads\. Default: enabled +. +.TP +\fB\-\-skip\-cask\-deps\fR +Skip installing cask dependencies\. . .TP \fB\-\-greedy\fR -Upgrade casks with \fBauto_updates\fR or \fBversion :latest\fR +Also include casks with \fBauto_updates true\fR or \fBversion :latest\fR\. . .SS "\fBuses\fR [\fIoptions\fR] \fIformula\fR" Show formulae that specify \fIformula\fR as a dependency (i\.e\. show dependents of \fIformula\fR)\. When given multiple formula arguments, show the intersection of formulae that use \fIformula\fR\. By default, \fBuses\fR shows all formulae that specify \fIformula\fR as a required or recommended dependency for their stable builds\. From 727d8546217eadf22924ece4100b1bf40c9169c8 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 1 Oct 2020 04:20:58 +0200 Subject: [PATCH 08/11] Add missing variable. --- Library/Homebrew/cli/named_args.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/cli/named_args.rb b/Library/Homebrew/cli/named_args.rb index ce9e8ea8f2..ea98cf12a8 100644 --- a/Library/Homebrew/cli/named_args.rb +++ b/Library/Homebrew/cli/named_args.rb @@ -60,7 +60,7 @@ module Homebrew if only != :formula begin return Cask::CaskLoader.load(name, config: Cask::Config.from_args(@parent)) - rescue Cask::CaskUnavailableError + rescue Cask::CaskUnavailableError => e raise e if only == :cask end end From 7743fed77bb4cee2100ff78c82d238992cedfb72 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 3 Oct 2020 02:45:32 +0200 Subject: [PATCH 09/11] =?UTF-8?q?Add=20=E2=80=9CGLOBAL=20CASK=20OPTIONS?= =?UTF-8?q?=E2=80=9D=20section=20to=20man=20page.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Library/Homebrew/cask/cmd.rb | 68 +---- Library/Homebrew/cli/parser.rb | 82 +++++- Library/Homebrew/cmd/install.rb | 20 +- Library/Homebrew/cmd/reinstall.rb | 4 +- Library/Homebrew/cmd/upgrade.rb | 5 +- Library/Homebrew/dev-cmd/man.rb | 16 +- Library/Homebrew/manpages/brew-cask.1.md | 1 - Library/Homebrew/manpages/brew.1.md.erb | 4 + docs/Manpage.md | 171 ++++--------- manpages/brew.1 | 303 +++++------------------ 10 files changed, 226 insertions(+), 448 deletions(-) delete mode 100644 Library/Homebrew/manpages/brew-cask.1.md diff --git a/Library/Homebrew/cask/cmd.rb b/Library/Homebrew/cask/cmd.rb index 644737c24b..38795bffe3 100644 --- a/Library/Homebrew/cask/cmd.rb +++ b/Library/Homebrew/cask/cmd.rb @@ -79,70 +79,6 @@ module Cask EOS end - OPTIONS = [ - [:flag, "--appdir=", { - description: "Target location for Applications. " \ - "Default: `#{Config::DEFAULT_DIRS[:appdir]}`", - }], - [:flag, "--colorpickerdir=", { - description: "Target location for Color Pickers. " \ - "Default: `#{Config::DEFAULT_DIRS[:colorpickerdir]}`", - }], - [:flag, "--prefpanedir=", { - description: "Target location for Preference Panes. " \ - "Default: `#{Config::DEFAULT_DIRS[:prefpanedir]}`", - }], - [:flag, "--qlplugindir=", { - description: "Target location for QuickLook Plugins. " \ - "Default: `#{Config::DEFAULT_DIRS[:qlplugindir]}`", - }], - [:flag, "--mdimporterdir=", { - description: "Target location for Spotlight Plugins. " \ - "Default: `#{Config::DEFAULT_DIRS[:mdimporterdir]}`", - }], - [:flag, "--dictionarydir=", { - description: "Target location for Dictionaries. " \ - "Default: `#{Config::DEFAULT_DIRS[:dictionarydir]}`", - }], - [:flag, "--fontdir=", { - description: "Target location for Fonts. " \ - "Default: `#{Config::DEFAULT_DIRS[:fontdir]}`", - }], - [:flag, "--servicedir=", { - description: "Target location for Services. " \ - "Default: `#{Config::DEFAULT_DIRS[:servicedir]}`", - }], - [:flag, "--input_methoddir=", { - description: "Target location for Input Methods. " \ - "Default: `#{Config::DEFAULT_DIRS[:input_methoddir]}`", - }], - [:flag, "--internet_plugindir=", { - description: "Target location for Internet Plugins. " \ - "Default: `#{Config::DEFAULT_DIRS[:internet_plugindir]}`", - }], - [:flag, "--audio_unit_plugindir=", { - description: "Target location for Audio Unit Plugins. " \ - "Default: `#{Config::DEFAULT_DIRS[:audio_unit_plugindir]}`", - }], - [:flag, "--vst_plugindir=", { - description: "Target location for VST Plugins. " \ - "Default: `#{Config::DEFAULT_DIRS[:vst_plugindir]}`", - }], - [:flag, "--vst3_plugindir=", { - description: "Target location for VST3 Plugins. " \ - "Default: `#{Config::DEFAULT_DIRS[:vst3_plugindir]}`", - }], - [:flag, "--screen_saverdir=", { - description: "Target location for Screen Savers. " \ - "Default: `#{Config::DEFAULT_DIRS[:screen_saverdir]}`", - }], - [:comma_array, "--language", { - description: "Set language of the Cask to install. The first matching " \ - "language is used, otherwise the default language on the Cask. " \ - "The default value is the `language of your system`", - }], - ].freeze - def self.parser(&block) Homebrew::CLI::Parser.new do if block_given? @@ -155,9 +91,7 @@ module Cask EOS end - OPTIONS.each do |option| - send(*option) - end + cask_options end end diff --git a/Library/Homebrew/cli/parser.rb b/Library/Homebrew/cli/parser.rb index d1ee78f854..2bc86bc4e0 100644 --- a/Library/Homebrew/cli/parser.rb +++ b/Library/Homebrew/cli/parser.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "env_config" +require "cask/config" require "cli/args" require "optparse" require "set" @@ -26,12 +27,78 @@ module Homebrew end end + def self.global_cask_options + [ + [:flag, "--appdir=", { + description: "Target location for Applications. " \ + "Default: `#{Cask::Config::DEFAULT_DIRS[:appdir]}`", + }], + [:flag, "--colorpickerdir=", { + description: "Target location for Color Pickers. " \ + "Default: `#{Cask::Config::DEFAULT_DIRS[:colorpickerdir]}`", + }], + [:flag, "--prefpanedir=", { + description: "Target location for Preference Panes. " \ + "Default: `#{Cask::Config::DEFAULT_DIRS[:prefpanedir]}`", + }], + [:flag, "--qlplugindir=", { + description: "Target location for QuickLook Plugins. " \ + "Default: `#{Cask::Config::DEFAULT_DIRS[:qlplugindir]}`", + }], + [:flag, "--mdimporterdir=", { + description: "Target location for Spotlight Plugins. " \ + "Default: `#{Cask::Config::DEFAULT_DIRS[:mdimporterdir]}`", + }], + [:flag, "--dictionarydir=", { + description: "Target location for Dictionaries. " \ + "Default: `#{Cask::Config::DEFAULT_DIRS[:dictionarydir]}`", + }], + [:flag, "--fontdir=", { + description: "Target location for Fonts. " \ + "Default: `#{Cask::Config::DEFAULT_DIRS[:fontdir]}`", + }], + [:flag, "--servicedir=", { + description: "Target location for Services. " \ + "Default: `#{Cask::Config::DEFAULT_DIRS[:servicedir]}`", + }], + [:flag, "--input_methoddir=", { + description: "Target location for Input Methods. " \ + "Default: `#{Cask::Config::DEFAULT_DIRS[:input_methoddir]}`", + }], + [:flag, "--internet_plugindir=", { + description: "Target location for Internet Plugins. " \ + "Default: `#{Cask::Config::DEFAULT_DIRS[:internet_plugindir]}`", + }], + [:flag, "--audio_unit_plugindir=", { + description: "Target location for Audio Unit Plugins. " \ + "Default: `#{Cask::Config::DEFAULT_DIRS[:audio_unit_plugindir]}`", + }], + [:flag, "--vst_plugindir=", { + description: "Target location for VST Plugins. " \ + "Default: `#{Cask::Config::DEFAULT_DIRS[:vst_plugindir]}`", + }], + [:flag, "--vst3_plugindir=", { + description: "Target location for VST3 Plugins. " \ + "Default: `#{Cask::Config::DEFAULT_DIRS[:vst3_plugindir]}`", + }], + [:flag, "--screen_saverdir=", { + description: "Target location for Screen Savers. " \ + "Default: `#{Cask::Config::DEFAULT_DIRS[:screen_saverdir]}`", + }], + [:comma_array, "--language", { + description: "Set language of the Cask to install. The first matching " \ + "language is used, otherwise the default language on the Cask. " \ + "The default value is the `language of your system`", + }], + ] + end + def self.global_options [ - ["-d", "--debug", "Display any debugging information."], - ["-q", "--quiet", "Suppress any warnings."], + ["-d", "--debug", "Display any debugging information."], + ["-q", "--quiet", "Suppress any warnings."], ["-v", "--verbose", "Make some output more verbose."], - ["-h", "--help", "Show this message."], + ["-h", "--help", "Show this message."], ] end @@ -211,6 +278,8 @@ module Homebrew else switch name, description: description end + + conflicts "--cask", name end end end @@ -254,6 +323,13 @@ module Homebrew .gsub(/\*(.*?)\*/m, "#{Tty.underline}\\1#{Tty.reset}") end + def cask_options + self.class.global_cask_options.each do |method, *args, **options| + send(method, *args, **options) + conflicts "--formula", args.last + end + end + def formula_options @formula_options = true end diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index e4bd2a31ab..824e4af6f2 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -22,7 +22,6 @@ module Homebrew [:switch, "--cask", "--casks", { description: "Treat all named arguments as casks.", }], - *Cask::Cmd::OPTIONS, *Cask::Cmd::AbstractCommand::OPTIONS, *Cask::Cmd::Install::OPTIONS, ] @@ -132,17 +131,18 @@ module Homebrew conflicts "--ignore-dependencies", "--only-dependencies" conflicts "--build-from-source", "--build-bottle", "--force-bottle" - formula_only_options.each do |options| - send(*options) - conflicts "--cask", options[-2] + formula_only_options.each do |*args, **options| + send(*args, **options) + conflicts "--cask", args.last end - - cask_only_options.each do |options| - send(*options) - conflicts "--formula", options[-2] - end - formula_options + + cask_only_options.each do |*args, **options| + send(*args, **options) + conflicts "--formula", args.last + end + cask_options + min_named 1 end end diff --git a/Library/Homebrew/cmd/reinstall.rb b/Library/Homebrew/cmd/reinstall.rb index 4aa8b0be3f..c760cfa578 100644 --- a/Library/Homebrew/cmd/reinstall.rb +++ b/Library/Homebrew/cmd/reinstall.rb @@ -20,7 +20,6 @@ module Homebrew [:switch, "--cask", "--casks", { description: "Treat all named arguments as casks.", }], - *Cask::Cmd::OPTIONS, *Cask::Cmd::AbstractCommand::OPTIONS, ] @@ -73,13 +72,14 @@ module Homebrew send(*options) conflicts "--cask", options[-2] end + formula_options cask_only_options.each do |options| send(*options) conflicts "--formula", options[-2] end + cask_options - formula_options min_named 1 end end diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb index fe7b6fc2bb..2af6ee603c 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -17,7 +17,6 @@ module Homebrew description: "Treat all named arguments as casks. If no named arguments " \ "are specified, upgrade only outdated casks.", }], - *Cask::Cmd::OPTIONS, *Cask::Cmd::AbstractCommand::OPTIONS, *Cask::Cmd::Upgrade::OPTIONS, ] @@ -85,13 +84,13 @@ module Homebrew send(*options) conflicts "--cask", options[-2] end + formula_options cask_only_options.each do |options| send(*options) conflicts "--formula", options[-2] end - - formula_options + cask_options end end diff --git a/Library/Homebrew/dev-cmd/man.rb b/Library/Homebrew/dev-cmd/man.rb index e34fe3cfcb..cea445b3d7 100644 --- a/Library/Homebrew/dev-cmd/man.rb +++ b/Library/Homebrew/dev-cmd/man.rb @@ -66,6 +66,7 @@ module Homebrew variables[:developer_commands] = generate_cmd_manpages(Commands.internal_developer_commands_paths) variables[:official_external_commands] = generate_cmd_manpages(Commands.official_external_commands_paths(quiet: quiet)) + variables[:global_cask_options] = global_cask_options_manpage variables[:global_options] = global_options_manpage variables[:environment_variables] = env_vars_manpage @@ -171,7 +172,12 @@ module Homebrew def cmd_parser_manpage_lines(cmd_parser) lines = [format_usage_banner(cmd_parser.usage_banner_text)] lines += cmd_parser.processed_options.map do |short, long, _, desc| - next if !long.nil? && Homebrew::CLI::Parser.global_options.include?([short, long, desc]) + if long.present? + next if Homebrew::CLI::Parser.global_options.include?([short, long, desc]) + next if Homebrew::CLI::Parser.global_cask_options.any? do |_, option, description:, **| + [long, "#{long}="].include?(option) && description == desc + end + end generate_option_doc(short, long, desc) end.reject(&:blank?) @@ -203,6 +209,14 @@ module Homebrew lines end + def global_cask_options_manpage + lines = ["These options are applicable to subcommands accepting a `--cask` flag and all `cask` commands.\n"] + lines += Homebrew::CLI::Parser.global_cask_options.map do |_, long, description:, **| + generate_option_doc(nil, long, description) + end + lines.join("\n") + end + def global_options_manpage lines = ["These options are applicable across multiple subcommands.\n"] lines += Homebrew::CLI::Parser.global_options.map do |short, long, desc| diff --git a/Library/Homebrew/manpages/brew-cask.1.md b/Library/Homebrew/manpages/brew-cask.1.md deleted file mode 100644 index 8b13789179..0000000000 --- a/Library/Homebrew/manpages/brew-cask.1.md +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Library/Homebrew/manpages/brew.1.md.erb b/Library/Homebrew/manpages/brew.1.md.erb index 593037011f..6d4773cd77 100644 --- a/Library/Homebrew/manpages/brew.1.md.erb +++ b/Library/Homebrew/manpages/brew.1.md.erb @@ -59,6 +59,10 @@ If no search term is provided, all locally available formulae are listed. <%= developer_commands %> +## GLOBAL CASK OPTIONS + +<%= global_cask_options %> + ## GLOBAL OPTIONS <%= global_options %> diff --git a/docs/Manpage.md b/docs/Manpage.md index 3298d50e85..2e5267b34c 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -118,37 +118,6 @@ Commands: See also: `man brew` -* `--appdir`: - Target location for Applications. Default: `/Applications` -* `--colorpickerdir`: - Target location for Color Pickers. Default: `~/Library/ColorPickers` -* `--prefpanedir`: - Target location for Preference Panes. Default: `~/Library/PreferencePanes` -* `--qlplugindir`: - Target location for QuickLook Plugins. Default: `~/Library/QuickLook` -* `--mdimporterdir`: - Target location for Spotlight Plugins. Default: `~/Library/Spotlight` -* `--dictionarydir`: - Target location for Dictionaries. Default: `~/Library/Dictionaries` -* `--fontdir`: - Target location for Fonts. Default: `~/Library/Fonts` -* `--servicedir`: - Target location for Services. Default: `~/Library/Services` -* `--input_methoddir`: - Target location for Input Methods. Default: `~/Library/Input Methods` -* `--internet_plugindir`: - Target location for Internet Plugins. Default: `~/Library/Internet Plug-Ins` -* `--audio_unit_plugindir`: - Target location for Audio Unit Plugins. Default: `~/Library/Audio/Plug-Ins/Components` -* `--vst_plugindir`: - Target location for VST Plugins. Default: `~/Library/Audio/Plug-Ins/VST` -* `--vst3_plugindir`: - Target location for VST3 Plugins. Default: `~/Library/Audio/Plug-Ins/VST3` -* `--screen_saverdir`: - Target location for Screen Savers. Default: `~/Library/Screen Savers` -* `--language`: - Set language of the Cask to install. The first matching language is used, otherwise the default language on the Cask. The default value is the `language of your system` - ### `cleanup` [*`options`*] [*`formula`*|*`cask`*] Remove stale lock files and outdated downloads for all formulae and casks, @@ -352,36 +321,6 @@ the installed formulae or, every 30 days, for all formulae. Create a Git repository, useful for creating patches to the software. * `--cask`: Treat all named arguments as casks. -* `--appdir`: - Target location for Applications. Default: `/Applications` -* `--colorpickerdir`: - Target location for Color Pickers. Default: `~/Library/ColorPickers` -* `--prefpanedir`: - Target location for Preference Panes. Default: `~/Library/PreferencePanes` -* `--qlplugindir`: - Target location for QuickLook Plugins. Default: `~/Library/QuickLook` -* `--mdimporterdir`: - Target location for Spotlight Plugins. Default: `~/Library/Spotlight` -* `--dictionarydir`: - Target location for Dictionaries. Default: `~/Library/Dictionaries` -* `--fontdir`: - Target location for Fonts. Default: `~/Library/Fonts` -* `--servicedir`: - Target location for Services. Default: `~/Library/Services` -* `--input_methoddir`: - Target location for Input Methods. Default: `~/Library/Input Methods` -* `--internet_plugindir`: - Target location for Internet Plugins. Default: `~/Library/Internet Plug-Ins` -* `--audio_unit_plugindir`: - Target location for Audio Unit Plugins. Default: `~/Library/Audio/Plug-Ins/Components` -* `--vst_plugindir`: - Target location for VST Plugins. Default: `~/Library/Audio/Plug-Ins/VST` -* `--vst3_plugindir`: - Target location for VST3 Plugins. Default: `~/Library/Audio/Plug-Ins/VST3` -* `--screen_saverdir`: - Target location for Screen Savers. Default: `~/Library/Screen Savers` -* `--language`: - Set language of the Cask to install. The first matching language is used, otherwise the default language on the Cask. The default value is the `language of your system` * `--[no-]binaries`: Disable/enable linking of helper executables. Default: enabled * `--require-sha`: @@ -552,36 +491,6 @@ reinstalled formulae or, every 30 days, for all formulae. Print install times for each formula at the end of the run. * `--cask`: Treat all named arguments as casks. -* `--appdir`: - Target location for Applications. Default: `/Applications` -* `--colorpickerdir`: - Target location for Color Pickers. Default: `~/Library/ColorPickers` -* `--prefpanedir`: - Target location for Preference Panes. Default: `~/Library/PreferencePanes` -* `--qlplugindir`: - Target location for QuickLook Plugins. Default: `~/Library/QuickLook` -* `--mdimporterdir`: - Target location for Spotlight Plugins. Default: `~/Library/Spotlight` -* `--dictionarydir`: - Target location for Dictionaries. Default: `~/Library/Dictionaries` -* `--fontdir`: - Target location for Fonts. Default: `~/Library/Fonts` -* `--servicedir`: - Target location for Services. Default: `~/Library/Services` -* `--input_methoddir`: - Target location for Input Methods. Default: `~/Library/Input Methods` -* `--internet_plugindir`: - Target location for Internet Plugins. Default: `~/Library/Internet Plug-Ins` -* `--audio_unit_plugindir`: - Target location for Audio Unit Plugins. Default: `~/Library/Audio/Plug-Ins/Components` -* `--vst_plugindir`: - Target location for VST Plugins. Default: `~/Library/Audio/Plug-Ins/VST` -* `--vst3_plugindir`: - Target location for VST3 Plugins. Default: `~/Library/Audio/Plug-Ins/VST3` -* `--screen_saverdir`: - Target location for Screen Savers. Default: `~/Library/Screen Savers` -* `--language`: - Set language of the Cask to install. The first matching language is used, otherwise the default language on the Cask. The default value is the `language of your system` * `--[no-]binaries`: Disable/enable linking of helper executables. Default: enabled * `--require-sha`: @@ -745,36 +654,6 @@ upgraded formulae or, every 30 days, for all formulae. Print install times for each formula at the end of the run. * `--cask`: Treat all named arguments as casks. If no named arguments are specified, upgrade only outdated casks. -* `--appdir`: - Target location for Applications. Default: `/Applications` -* `--colorpickerdir`: - Target location for Color Pickers. Default: `~/Library/ColorPickers` -* `--prefpanedir`: - Target location for Preference Panes. Default: `~/Library/PreferencePanes` -* `--qlplugindir`: - Target location for QuickLook Plugins. Default: `~/Library/QuickLook` -* `--mdimporterdir`: - Target location for Spotlight Plugins. Default: `~/Library/Spotlight` -* `--dictionarydir`: - Target location for Dictionaries. Default: `~/Library/Dictionaries` -* `--fontdir`: - Target location for Fonts. Default: `~/Library/Fonts` -* `--servicedir`: - Target location for Services. Default: `~/Library/Services` -* `--input_methoddir`: - Target location for Input Methods. Default: `~/Library/Input Methods` -* `--internet_plugindir`: - Target location for Internet Plugins. Default: `~/Library/Internet Plug-Ins` -* `--audio_unit_plugindir`: - Target location for Audio Unit Plugins. Default: `~/Library/Audio/Plug-Ins/Components` -* `--vst_plugindir`: - Target location for VST Plugins. Default: `~/Library/Audio/Plug-Ins/VST` -* `--vst3_plugindir`: - Target location for VST3 Plugins. Default: `~/Library/Audio/Plug-Ins/VST3` -* `--screen_saverdir`: - Target location for Screen Savers. Default: `~/Library/Screen Savers` -* `--language`: - Set language of the Cask to install. The first matching language is used, otherwise the default language on the Cask. The default value is the `language of your system` * `--[no-]binaries`: Disable/enable linking of helper executables. Default: enabled * `--require-sha`: @@ -1439,6 +1318,55 @@ If no options are passed, use `origin/master` as the start commit. Install and commit Homebrew's vendored gems. +## GLOBAL CASK OPTIONS + +These options are applicable to subcommands accepting a `--cask` flag and all `cask` commands. + +* `--appdir=`: + Target location for Applications. Default: `/Applications` + +* `--colorpickerdir=`: + Target location for Color Pickers. Default: `~/Library/ColorPickers` + +* `--prefpanedir=`: + Target location for Preference Panes. Default: `~/Library/PreferencePanes` + +* `--qlplugindir=`: + Target location for QuickLook Plugins. Default: `~/Library/QuickLook` + +* `--mdimporterdir=`: + Target location for Spotlight Plugins. Default: `~/Library/Spotlight` + +* `--dictionarydir=`: + Target location for Dictionaries. Default: `~/Library/Dictionaries` + +* `--fontdir=`: + Target location for Fonts. Default: `~/Library/Fonts` + +* `--servicedir=`: + Target location for Services. Default: `~/Library/Services` + +* `--input_methoddir=`: + Target location for Input Methods. Default: `~/Library/Input Methods` + +* `--internet_plugindir=`: + Target location for Internet Plugins. Default: `~/Library/Internet Plug-Ins` + +* `--audio_unit_plugindir=`: + Target location for Audio Unit Plugins. Default: `~/Library/Audio/Plug-Ins/Components` + +* `--vst_plugindir=`: + Target location for VST Plugins. Default: `~/Library/Audio/Plug-Ins/VST` + +* `--vst3_plugindir=`: + Target location for VST3 Plugins. Default: `~/Library/Audio/Plug-Ins/VST3` + +* `--screen_saverdir=`: + Target location for Screen Savers. Default: `~/Library/Screen Savers` + +* `--language`: + Set language of the Cask to install. The first matching language is used, otherwise the default language on the Cask. The default value is the `language of your system` + ## GLOBAL OPTIONS These options are applicable across multiple subcommands. @@ -1938,6 +1866,7 @@ See our issues on GitHub: [ESSENTIAL COMMANDS]: #ESSENTIAL-COMMANDS "ESSENTIAL COMMANDS" [COMMANDS]: #COMMANDS "COMMANDS" [DEVELOPER COMMANDS]: #DEVELOPER-COMMANDS "DEVELOPER COMMANDS" +[GLOBAL CASK OPTIONS]: #GLOBAL-CASK-OPTIONS "GLOBAL CASK OPTIONS" [GLOBAL OPTIONS]: #GLOBAL-OPTIONS "GLOBAL OPTIONS" [OFFICIAL EXTERNAL COMMANDS]: #OFFICIAL-EXTERNAL-COMMANDS "OFFICIAL EXTERNAL COMMANDS" [CUSTOM EXTERNAL COMMANDS]: #CUSTOM-EXTERNAL-COMMANDS "CUSTOM EXTERNAL COMMANDS" diff --git a/manpages/brew.1 b/manpages/brew.1 index ec67fdec6e..6f296021cb 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -172,66 +172,6 @@ Zaps all files associated with the given \fIcask\fR .P See also: \fBman brew\fR . -.TP -\fB\-\-appdir\fR -Target location for Applications\. Default: \fB/Applications\fR -. -.TP -\fB\-\-colorpickerdir\fR -Target location for Color Pickers\. Default: \fB~/Library/ColorPickers\fR -. -.TP -\fB\-\-prefpanedir\fR -Target location for Preference Panes\. Default: \fB~/Library/PreferencePanes\fR -. -.TP -\fB\-\-qlplugindir\fR -Target location for QuickLook Plugins\. Default: \fB~/Library/QuickLook\fR -. -.TP -\fB\-\-mdimporterdir\fR -Target location for Spotlight Plugins\. Default: \fB~/Library/Spotlight\fR -. -.TP -\fB\-\-dictionarydir\fR -Target location for Dictionaries\. Default: \fB~/Library/Dictionaries\fR -. -.TP -\fB\-\-fontdir\fR -Target location for Fonts\. Default: \fB~/Library/Fonts\fR -. -.TP -\fB\-\-servicedir\fR -Target location for Services\. Default: \fB~/Library/Services\fR -. -.TP -\fB\-\-input_methoddir\fR -Target location for Input Methods\. Default: \fB~/Library/Input Methods\fR -. -.TP -\fB\-\-internet_plugindir\fR -Target location for Internet Plugins\. Default: \fB~/Library/Internet Plug\-Ins\fR -. -.TP -\fB\-\-audio_unit_plugindir\fR -Target location for Audio Unit Plugins\. Default: \fB~/Library/Audio/Plug\-Ins/Components\fR -. -.TP -\fB\-\-vst_plugindir\fR -Target location for VST Plugins\. Default: \fB~/Library/Audio/Plug\-Ins/VST\fR -. -.TP -\fB\-\-vst3_plugindir\fR -Target location for VST3 Plugins\. Default: \fB~/Library/Audio/Plug\-Ins/VST3\fR -. -.TP -\fB\-\-screen_saverdir\fR -Target location for Screen Savers\. Default: \fB~/Library/Screen Savers\fR -. -.TP -\fB\-\-language\fR -Set language of the Cask to install\. The first matching language is used, otherwise the default language on the Cask\. The default value is the \fBlanguage of your system\fR -. .SS "\fBcleanup\fR [\fIoptions\fR] [\fIformula\fR|\fIcask\fR]" Remove stale lock files and outdated downloads for all formulae and casks, and remove old versions of installed formulae\. If arguments are specified, only do this for the given formulae and casks\. Removes all downloads more than 120 days old\. This can be adjusted with \fBHOMEBREW_CLEANUP_MAX_AGE_DAYS\fR\. . @@ -532,66 +472,6 @@ Create a Git repository, useful for creating patches to the software\. Treat all named arguments as casks\. . .TP -\fB\-\-appdir\fR -Target location for Applications\. Default: \fB/Applications\fR -. -.TP -\fB\-\-colorpickerdir\fR -Target location for Color Pickers\. Default: \fB~/Library/ColorPickers\fR -. -.TP -\fB\-\-prefpanedir\fR -Target location for Preference Panes\. Default: \fB~/Library/PreferencePanes\fR -. -.TP -\fB\-\-qlplugindir\fR -Target location for QuickLook Plugins\. Default: \fB~/Library/QuickLook\fR -. -.TP -\fB\-\-mdimporterdir\fR -Target location for Spotlight Plugins\. Default: \fB~/Library/Spotlight\fR -. -.TP -\fB\-\-dictionarydir\fR -Target location for Dictionaries\. Default: \fB~/Library/Dictionaries\fR -. -.TP -\fB\-\-fontdir\fR -Target location for Fonts\. Default: \fB~/Library/Fonts\fR -. -.TP -\fB\-\-servicedir\fR -Target location for Services\. Default: \fB~/Library/Services\fR -. -.TP -\fB\-\-input_methoddir\fR -Target location for Input Methods\. Default: \fB~/Library/Input Methods\fR -. -.TP -\fB\-\-internet_plugindir\fR -Target location for Internet Plugins\. Default: \fB~/Library/Internet Plug\-Ins\fR -. -.TP -\fB\-\-audio_unit_plugindir\fR -Target location for Audio Unit Plugins\. Default: \fB~/Library/Audio/Plug\-Ins/Components\fR -. -.TP -\fB\-\-vst_plugindir\fR -Target location for VST Plugins\. Default: \fB~/Library/Audio/Plug\-Ins/VST\fR -. -.TP -\fB\-\-vst3_plugindir\fR -Target location for VST3 Plugins\. Default: \fB~/Library/Audio/Plug\-Ins/VST3\fR -. -.TP -\fB\-\-screen_saverdir\fR -Target location for Screen Savers\. Default: \fB~/Library/Screen Savers\fR -. -.TP -\fB\-\-language\fR -Set language of the Cask to install\. The first matching language is used, otherwise the default language on the Cask\. The default value is the \fBlanguage of your system\fR -. -.TP \fB\-\-[no\-]binaries\fR Disable/enable linking of helper executables\. Default: enabled . @@ -826,66 +706,6 @@ Print install times for each formula at the end of the run\. Treat all named arguments as casks\. . .TP -\fB\-\-appdir\fR -Target location for Applications\. Default: \fB/Applications\fR -. -.TP -\fB\-\-colorpickerdir\fR -Target location for Color Pickers\. Default: \fB~/Library/ColorPickers\fR -. -.TP -\fB\-\-prefpanedir\fR -Target location for Preference Panes\. Default: \fB~/Library/PreferencePanes\fR -. -.TP -\fB\-\-qlplugindir\fR -Target location for QuickLook Plugins\. Default: \fB~/Library/QuickLook\fR -. -.TP -\fB\-\-mdimporterdir\fR -Target location for Spotlight Plugins\. Default: \fB~/Library/Spotlight\fR -. -.TP -\fB\-\-dictionarydir\fR -Target location for Dictionaries\. Default: \fB~/Library/Dictionaries\fR -. -.TP -\fB\-\-fontdir\fR -Target location for Fonts\. Default: \fB~/Library/Fonts\fR -. -.TP -\fB\-\-servicedir\fR -Target location for Services\. Default: \fB~/Library/Services\fR -. -.TP -\fB\-\-input_methoddir\fR -Target location for Input Methods\. Default: \fB~/Library/Input Methods\fR -. -.TP -\fB\-\-internet_plugindir\fR -Target location for Internet Plugins\. Default: \fB~/Library/Internet Plug\-Ins\fR -. -.TP -\fB\-\-audio_unit_plugindir\fR -Target location for Audio Unit Plugins\. Default: \fB~/Library/Audio/Plug\-Ins/Components\fR -. -.TP -\fB\-\-vst_plugindir\fR -Target location for VST Plugins\. Default: \fB~/Library/Audio/Plug\-Ins/VST\fR -. -.TP -\fB\-\-vst3_plugindir\fR -Target location for VST3 Plugins\. Default: \fB~/Library/Audio/Plug\-Ins/VST3\fR -. -.TP -\fB\-\-screen_saverdir\fR -Target location for Screen Savers\. Default: \fB~/Library/Screen Savers\fR -. -.TP -\fB\-\-language\fR -Set language of the Cask to install\. The first matching language is used, otherwise the default language on the Cask\. The default value is the \fBlanguage of your system\fR -. -.TP \fB\-\-[no\-]binaries\fR Disable/enable linking of helper executables\. Default: enabled . @@ -1098,66 +918,6 @@ Print install times for each formula at the end of the run\. Treat all named arguments as casks\. If no named arguments are specified, upgrade only outdated casks\. . .TP -\fB\-\-appdir\fR -Target location for Applications\. Default: \fB/Applications\fR -. -.TP -\fB\-\-colorpickerdir\fR -Target location for Color Pickers\. Default: \fB~/Library/ColorPickers\fR -. -.TP -\fB\-\-prefpanedir\fR -Target location for Preference Panes\. Default: \fB~/Library/PreferencePanes\fR -. -.TP -\fB\-\-qlplugindir\fR -Target location for QuickLook Plugins\. Default: \fB~/Library/QuickLook\fR -. -.TP -\fB\-\-mdimporterdir\fR -Target location for Spotlight Plugins\. Default: \fB~/Library/Spotlight\fR -. -.TP -\fB\-\-dictionarydir\fR -Target location for Dictionaries\. Default: \fB~/Library/Dictionaries\fR -. -.TP -\fB\-\-fontdir\fR -Target location for Fonts\. Default: \fB~/Library/Fonts\fR -. -.TP -\fB\-\-servicedir\fR -Target location for Services\. Default: \fB~/Library/Services\fR -. -.TP -\fB\-\-input_methoddir\fR -Target location for Input Methods\. Default: \fB~/Library/Input Methods\fR -. -.TP -\fB\-\-internet_plugindir\fR -Target location for Internet Plugins\. Default: \fB~/Library/Internet Plug\-Ins\fR -. -.TP -\fB\-\-audio_unit_plugindir\fR -Target location for Audio Unit Plugins\. Default: \fB~/Library/Audio/Plug\-Ins/Components\fR -. -.TP -\fB\-\-vst_plugindir\fR -Target location for VST Plugins\. Default: \fB~/Library/Audio/Plug\-Ins/VST\fR -. -.TP -\fB\-\-vst3_plugindir\fR -Target location for VST3 Plugins\. Default: \fB~/Library/Audio/Plug\-Ins/VST3\fR -. -.TP -\fB\-\-screen_saverdir\fR -Target location for Screen Savers\. Default: \fB~/Library/Screen Savers\fR -. -.TP -\fB\-\-language\fR -Set language of the Cask to install\. The first matching language is used, otherwise the default language on the Cask\. The default value is the \fBlanguage of your system\fR -. -.TP \fB\-\-[no\-]binaries\fR Disable/enable linking of helper executables\. Default: enabled . @@ -2064,6 +1824,69 @@ Use the commit at the specified \fIdate\fR as the start commit\. .SS "\fBvendor\-gems\fR" Install and commit Homebrew\'s vendored gems\. . +.SH "GLOBAL CASK OPTIONS" +These options are applicable to subcommands accepting a \fB\-\-cask\fR flag and all \fBcask\fR commands\. +. +.TP +\fB\-\-appdir=\fR +Target location for Applications\. Default: \fB/Applications\fR +. +.TP +\fB\-\-colorpickerdir=\fR +Target location for Color Pickers\. Default: \fB~/Library/ColorPickers\fR +. +.TP +\fB\-\-prefpanedir=\fR +Target location for Preference Panes\. Default: \fB~/Library/PreferencePanes\fR +. +.TP +\fB\-\-qlplugindir=\fR +Target location for QuickLook Plugins\. Default: \fB~/Library/QuickLook\fR +. +.TP +\fB\-\-mdimporterdir=\fR +Target location for Spotlight Plugins\. Default: \fB~/Library/Spotlight\fR +. +.TP +\fB\-\-dictionarydir=\fR +Target location for Dictionaries\. Default: \fB~/Library/Dictionaries\fR +. +.TP +\fB\-\-fontdir=\fR +Target location for Fonts\. Default: \fB~/Library/Fonts\fR +. +.TP +\fB\-\-servicedir=\fR +Target location for Services\. Default: \fB~/Library/Services\fR +. +.TP +\fB\-\-input_methoddir=\fR +Target location for Input Methods\. Default: \fB~/Library/Input Methods\fR +. +.TP +\fB\-\-internet_plugindir=\fR +Target location for Internet Plugins\. Default: \fB~/Library/Internet Plug\-Ins\fR +. +.TP +\fB\-\-audio_unit_plugindir=\fR +Target location for Audio Unit Plugins\. Default: \fB~/Library/Audio/Plug\-Ins/Components\fR +. +.TP +\fB\-\-vst_plugindir=\fR +Target location for VST Plugins\. Default: \fB~/Library/Audio/Plug\-Ins/VST\fR +. +.TP +\fB\-\-vst3_plugindir=\fR +Target location for VST3 Plugins\. Default: \fB~/Library/Audio/Plug\-Ins/VST3\fR +. +.TP +\fB\-\-screen_saverdir=\fR +Target location for Screen Savers\. Default: \fB~/Library/Screen Savers\fR +. +.TP +\fB\-\-language\fR +Set language of the Cask to install\. The first matching language is used, otherwise the default language on the Cask\. The default value is the \fBlanguage of your system\fR +. .SH "GLOBAL OPTIONS" These options are applicable across multiple subcommands\. . From d6b563e752b1b8a0c56858d5b249f013fdba75ad Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 8 Oct 2020 11:12:17 +0200 Subject: [PATCH 10/11] Support `min_named :formula_or_cask`. --- Library/Homebrew/cli/parser.rb | 8 +++++--- Library/Homebrew/cmd/install.rb | 2 +- Library/Homebrew/cmd/reinstall.rb | 2 +- Library/Homebrew/exceptions.rb | 7 +++++++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/cli/parser.rb b/Library/Homebrew/cli/parser.rb index 2bc86bc4e0..179c4c17a4 100644 --- a/Library/Homebrew/cli/parser.rb +++ b/Library/Homebrew/cli/parser.rb @@ -455,11 +455,13 @@ module Homebrew def check_named_args(args) min_exception = case @min_named_type when :cask - Cask::CaskUnspecifiedError.new + Cask::CaskUnspecifiedError when :formula - FormulaUnspecifiedError.new + FormulaUnspecifiedError + when :formula_or_cask + FormulaOrCaskUnspecifiedError when :keg - KegUnspecifiedError.new + KegUnspecifiedError else MinNamedArgumentsError.new(@min_named_args) end diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index 824e4af6f2..cfbd960e3f 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -143,7 +143,7 @@ module Homebrew end cask_options - min_named 1 + min_named :formula_or_cask end end diff --git a/Library/Homebrew/cmd/reinstall.rb b/Library/Homebrew/cmd/reinstall.rb index c760cfa578..0bb8b28069 100644 --- a/Library/Homebrew/cmd/reinstall.rb +++ b/Library/Homebrew/cmd/reinstall.rb @@ -80,7 +80,7 @@ module Homebrew end cask_options - min_named 1 + min_named :formula_or_cask end end diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index a18499f691..35913baf0a 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -27,6 +27,13 @@ class FormulaUnspecifiedError < UsageError end end +# Raised when a command expects a formula or cask and none was specified. +class FormulaOrCaskUnspecifiedError < UsageError + def initialize + super "this command requires a formula or cask argument" + end +end + # Raised when a command expects a keg and none was specified. class KegUnspecifiedError < UsageError def initialize From 10e3b63b7b7135a3e69f83b753285a566db738ac Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 8 Oct 2020 11:18:24 +0200 Subject: [PATCH 11/11] Inline `install`, `reinstall` and `upgrade` options. --- Library/Homebrew/cmd/install.rb | 177 +++++++++++++----------------- Library/Homebrew/cmd/reinstall.rb | 70 ++++++------ Library/Homebrew/cmd/upgrade.rb | 92 ++++++++-------- docs/Manpage.md | 2 + manpages/brew.1 | 4 + 5 files changed, 158 insertions(+), 187 deletions(-) diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index cfbd960e3f..2b62240616 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -18,97 +18,6 @@ module Homebrew module_function def install_args - cask_only_options = [ - [:switch, "--cask", "--casks", { - description: "Treat all named arguments as casks.", - }], - *Cask::Cmd::AbstractCommand::OPTIONS, - *Cask::Cmd::Install::OPTIONS, - ] - - formula_only_options = [ - [:switch, "--formula", "--formulae", { - description: "Treat all named arguments as formulae.", - }], - [:flag, "--env=", { - description: "If `std` is passed, use the standard build environment instead of superenv. "\ - "If `super` is passed, use superenv even if the formula specifies the "\ - "standard build environment.", - }], - [:switch, "--ignore-dependencies", { - description: "An unsupported Homebrew development flag to skip installing any dependencies of "\ - "any kind. If the dependencies are not already present, the formula will have issues. "\ - "If you're not developing Homebrew, consider adjusting your PATH rather than "\ - "using this flag.", - - }], - [:switch, "--only-dependencies", { - description: "Install the dependencies with specified options but do not install the "\ - "formula itself.", - - }], - [:flag, "--cc=", { - description: "Attempt to compile using the specified , which should be the "\ - "name of the compiler's executable, e.g. `gcc-7` for GCC 7. "\ - "In order to use LLVM's clang, specify `llvm_clang`. To use the "\ - "Apple-provided clang, specify `clang`. This option will only accept "\ - "compilers that are provided by Homebrew or bundled with macOS. "\ - "Please do not file issues if you encounter errors while using this option.", - - }], - [:switch, "-s", "--build-from-source", { - description: "Compile from source even if a bottle is provided. "\ - "Dependencies will still be installed from bottles if they are available.", - - }], - [:switch, "--force-bottle", { - description: "Install from a bottle if it exists for the current or newest version of "\ - "macOS, even if it would not normally be used for installation.", - - }], - [:switch, "--include-test", { - description: "Install testing dependencies required to run `brew test` .", - - }], - [:switch, "--HEAD", { - description: "If defines it, install the HEAD version, aka. master, trunk, unstable.", - - }], - [:switch, "--fetch-HEAD", { - description: "Fetch the upstream repository to detect if the HEAD installation of the "\ - "formula is outdated. Otherwise, the repository's HEAD will only be checked for "\ - "updates when a new stable or development version has been released.", - - }], - [:switch, "--keep-tmp", { - description: "Retain the temporary files created during installation.", - - }], - [:switch, "--build-bottle", { - description: "Prepare the formula for eventual bottling during installation, skipping any "\ - "post-install steps.", - - }], - [:flag, "--bottle-arch=", { - depends_on: "--build-bottle", - description: "Optimise bottles for the specified architecture rather than the oldest "\ - "architecture supported by the version of macOS the bottles are built on.", - - }], - [:switch, "--display-times", { - env: :display_install_times, - description: "Print install times for each formula at the end of the run.", - }], - [:switch, "-i", "--interactive", { - description: "Download and patch , then open a shell. This allows the user to "\ - "run `./configure --help` and otherwise determine how to turn the software "\ - "package into a Homebrew package.", - }], - [:switch, "-g", "--git", { - description: "Create a Git repository, useful for creating patches to the software.", - }], - ] - Homebrew::CLI::Parser.new do usage_banner <<~EOS `install` [] | @@ -120,29 +29,99 @@ module Homebrew the installed formulae or, every 30 days, for all formulae. EOS switch "-d", "--debug", - description: "If brewing fails, open an interactive debugging session with access to IRB "\ + description: "If brewing fails, open an interactive debugging session with access to IRB " \ "or a shell inside the temporary build directory." switch "-f", "--force", - description: "Install formulae without checking for previously installed keg-only or "\ + description: "Install formulae without checking for previously installed keg-only or " \ "non-migrated versions. Overwrite existing files when installing casks." switch "-v", "--verbose", description: "Print the verification and postinstall steps." + [ + [:switch, "--formula", "--formulae", { + description: "Treat all named arguments as formulae.", + }], + [:flag, "--env=", { + description: "If `std` is passed, use the standard build environment instead of superenv. If `super` is " \ + "passed, use superenv even if the formula specifies the standard build environment.", + }], + [:switch, "--ignore-dependencies", { + description: "An unsupported Homebrew development flag to skip installing any dependencies of any kind. " \ + "If the dependencies are not already present, the formula will have issues. If you're not " \ + "developing Homebrew, consider adjusting your PATH rather than using this flag.", + }], + [:switch, "--only-dependencies", { + description: "Install the dependencies with specified options but do not install the " \ + "formula itself.", + }], + [:flag, "--cc=", { + description: "Attempt to compile using the specified , which should be the name of the " \ + "compiler's executable, e.g. `gcc-7` for GCC 7. In order to use LLVM's clang, specify " \ + "`llvm_clang`. To use the Apple-provided clang, specify `clang`. This option will only " \ + "accept compilers that are provided by Homebrew or bundled with macOS. Please do not " \ + "file issues if you encounter errors while using this option.", + }], + [:switch, "-s", "--build-from-source", { + description: "Compile from source even if a bottle is provided. " \ + "Dependencies will still be installed from bottles if they are available.", + }], + [:switch, "--force-bottle", { + description: "Install from a bottle if it exists for the current or newest version of " \ + "macOS, even if it would not normally be used for installation.", + }], + [:switch, "--include-test", { + description: "Install testing dependencies required to run `brew test` .", + }], + [:switch, "--HEAD", { + description: "If defines it, install the HEAD version, aka. master, trunk, unstable.", + }], + [:switch, "--fetch-HEAD", { + description: "Fetch the upstream repository to detect if the HEAD installation of the " \ + "formula is outdated. Otherwise, the repository's HEAD will only be checked for " \ + "updates when a new stable or development version has been released.", + }], + [:switch, "--keep-tmp", { + description: "Retain the temporary files created during installation.", - conflicts "--ignore-dependencies", "--only-dependencies" - conflicts "--build-from-source", "--build-bottle", "--force-bottle" - - formula_only_options.each do |*args, **options| + }], + [:switch, "--build-bottle", { + description: "Prepare the formula for eventual bottling during installation, skipping any " \ + "post-install steps.", + }], + [:flag, "--bottle-arch=", { + depends_on: "--build-bottle", + description: "Optimise bottles for the specified architecture rather than the oldest " \ + "architecture supported by the version of macOS the bottles are built on.", + }], + [:switch, "--display-times", { + env: :display_install_times, + description: "Print install times for each formula at the end of the run.", + }], + [:switch, "-i", "--interactive", { + description: "Download and patch , then open a shell. This allows the user to " \ + "run `./configure --help` and otherwise determine how to turn the software " \ + "package into a Homebrew package.", + }], + [:switch, "-g", "--git", { + description: "Create a Git repository, useful for creating patches to the software.", + }], + ].each do |*args, **options| send(*args, **options) conflicts "--cask", args.last end formula_options - - cask_only_options.each do |*args, **options| + [ + [:switch, "--cask", "--casks", { description: "Treat all named arguments as casks." }], + *Cask::Cmd::AbstractCommand::OPTIONS, + *Cask::Cmd::Install::OPTIONS, + ].each do |*args, **options| send(*args, **options) conflicts "--formula", args.last end cask_options + conflicts "--ignore-dependencies", "--only-dependencies" + conflicts "--build-from-source", "--build-bottle", "--force-bottle" + min_named :formula_or_cask end end diff --git a/Library/Homebrew/cmd/reinstall.rb b/Library/Homebrew/cmd/reinstall.rb index 0bb8b28069..1c9d62a08f 100644 --- a/Library/Homebrew/cmd/reinstall.rb +++ b/Library/Homebrew/cmd/reinstall.rb @@ -16,38 +16,6 @@ module Homebrew module_function def reinstall_args - cask_only_options = [ - [:switch, "--cask", "--casks", { - description: "Treat all named arguments as casks.", - }], - *Cask::Cmd::AbstractCommand::OPTIONS, - ] - - formula_only_options = [ - [:switch, "--formula", "--formulae", { - description: "Treat all named arguments as formulae.", - }], - [:switch, "-s", "--build-from-source", { - description: "Compile from source even if a bottle is available.", - }], - [:switch, "-i", "--interactive", { - description: "Download and patch , then open a shell. This allows the user to "\ - "run `./configure --help` and otherwise determine how to turn the software "\ - "package into a Homebrew package.", - }], - [:switch, "--force-bottle", { - description: "Install from a bottle if it exists for the current or newest version of "\ - "macOS, even if it would not normally be used for installation.", - }], - [:switch, "--keep-tmp", { - description: "Retain the temporary files created during installation.", - }], - [:switch, "--display-times", { - env: :display_install_times, - description: "Print install times for each formula at the end of the run.", - }], - ] - Homebrew::CLI::Parser.new do usage_banner <<~EOS `reinstall` [] | @@ -59,27 +27,51 @@ module Homebrew reinstalled formulae or, every 30 days, for all formulae. EOS switch "-d", "--debug", - description: "If brewing fails, open an interactive debugging session with access to IRB "\ + description: "If brewing fails, open an interactive debugging session with access to IRB " \ "or a shell inside the temporary build directory." switch "-f", "--force", - description: "Install without checking for previously installed keg-only or "\ + description: "Install without checking for previously installed keg-only or " \ "non-migrated versions." switch "-v", "--verbose", description: "Print the verification and postinstall steps." - conflicts "--build-from-source", "--force-bottle" - - formula_only_options.each do |options| + [ + [:switch, "--formula", "--formulae", { description: "Treat all named arguments as formulae." }], + [:switch, "-s", "--build-from-source", { + description: "Compile from source even if a bottle is available.", + }], + [:switch, "-i", "--interactive", { + description: "Download and patch , then open a shell. This allows the user to " \ + "run `./configure --help` and otherwise determine how to turn the software " \ + "package into a Homebrew package.", + }], + [:switch, "--force-bottle", { + description: "Install from a bottle if it exists for the current or newest version of " \ + "macOS, even if it would not normally be used for installation.", + }], + [:switch, "--keep-tmp", { + description: "Retain the temporary files created during installation.", + }], + [:switch, "--display-times", { + env: :display_install_times, + description: "Print install times for each formula at the end of the run.", + }], + ].each do |options| send(*options) conflicts "--cask", options[-2] end formula_options - - cask_only_options.each do |options| + [ + [:switch, "--cask", "--casks", { description: "Treat all named arguments as casks." }], + *Cask::Cmd::AbstractCommand::OPTIONS, + *Cask::Cmd::Install::OPTIONS, + ].each do |options| send(*options) conflicts "--formula", options[-2] end cask_options + conflicts "--build-from-source", "--force-bottle" + min_named :formula_or_cask end end diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb index 2af6ee603c..44a32c9451 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -12,50 +12,6 @@ module Homebrew module_function def upgrade_args - cask_only_options = [ - [:switch, "--cask", "--casks", { - description: "Treat all named arguments as casks. If no named arguments " \ - "are specified, upgrade only outdated casks.", - }], - *Cask::Cmd::AbstractCommand::OPTIONS, - *Cask::Cmd::Upgrade::OPTIONS, - ] - - formula_only_options = [ - [:switch, "--formula", "--formulae", { - description: "Treat all named arguments as formulae. If no named arguments" \ - "are specified, upgrade only outdated formulae.", - }], - [:switch, "-s", "--build-from-source", { - description: "Compile from source even if a bottle is available.", - }], - [:switch, "-i", "--interactive", { - description: "Download and patch , then open a shell. This allows the user to "\ - "run `./configure --help` and otherwise determine how to turn the software "\ - "package into a Homebrew package.", - }], - [:switch, "--force-bottle", { - description: "Install from a bottle if it exists for the current or newest version of "\ - "macOS, even if it would not normally be used for installation.", - }], - [:switch, "--fetch-HEAD", { - description: "Fetch the upstream repository to detect if the HEAD installation of the "\ - "formula is outdated. Otherwise, the repository's HEAD will only be checked for "\ - "updates when a new stable or development version has been released.", - - }], - [:switch, "--ignore-pinned", { - description: "Set a successful exit status even if pinned formulae are not upgraded.", - }], - [:switch, "--keep-tmp", { - description: "Retain the temporary files created during installation.", - }], - [:switch, "--display-times", { - env: :display_install_times, - description: "Print install times for each formula at the end of the run.", - }], - ] - Homebrew::CLI::Parser.new do usage_banner <<~EOS `upgrade` [] [|] @@ -77,20 +33,58 @@ module Homebrew description: "Print the verification and postinstall steps." switch "-n", "--dry-run", description: "Show what would be upgraded, but do not actually upgrade anything." + [ + [:switch, "--formula", "--formulae", { + description: "Treat all named arguments as formulae. If no named arguments" \ + "are specified, upgrade only outdated formulae.", + }], + [:switch, "-s", "--build-from-source", { + description: "Compile from source even if a bottle is available.", + }], + [:switch, "-i", "--interactive", { + description: "Download and patch , then open a shell. This allows the user to "\ + "run `./configure --help` and otherwise determine how to turn the software "\ + "package into a Homebrew package.", + }], + [:switch, "--force-bottle", { + description: "Install from a bottle if it exists for the current or newest version of "\ + "macOS, even if it would not normally be used for installation.", + }], + [:switch, "--fetch-HEAD", { + description: "Fetch the upstream repository to detect if the HEAD installation of the "\ + "formula is outdated. Otherwise, the repository's HEAD will only be checked for "\ + "updates when a new stable or development version has been released.", - conflicts "--build-from-source", "--force-bottle" - - formula_only_options.each do |options| + }], + [:switch, "--ignore-pinned", { + description: "Set a successful exit status even if pinned formulae are not upgraded.", + }], + [:switch, "--keep-tmp", { + description: "Retain the temporary files created during installation.", + }], + [:switch, "--display-times", { + env: :display_install_times, + description: "Print install times for each formula at the end of the run.", + }], + ].each do |options| send(*options) conflicts "--cask", options[-2] end formula_options - - cask_only_options.each do |options| + [ + [:switch, "--cask", "--casks", { + description: "Treat all named arguments as casks. If no named arguments " \ + "are specified, upgrade only outdated casks.", + }], + *Cask::Cmd::AbstractCommand::OPTIONS, + *Cask::Cmd::Upgrade::OPTIONS, + ].each do |options| send(*options) conflicts "--formula", options[-2] end cask_options + + conflicts "--build-from-source", "--force-bottle" end end diff --git a/docs/Manpage.md b/docs/Manpage.md index 2e5267b34c..3b0f3ee42e 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -497,6 +497,8 @@ reinstalled formulae or, every 30 days, for all formulae. Require all casks to have a checksum. * `--[no-]quarantine`: Disable/enable quarantining of downloads. Default: enabled +* `--skip-cask-deps`: + Skip installing cask dependencies. ### `search` [*`options`*] [*`text`*|`/`*`text`*`/`] diff --git a/manpages/brew.1 b/manpages/brew.1 index 6f296021cb..512be112c6 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -717,6 +717,10 @@ Require all casks to have a checksum\. \fB\-\-[no\-]quarantine\fR Disable/enable quarantining of downloads\. Default: enabled . +.TP +\fB\-\-skip\-cask\-deps\fR +Skip installing cask dependencies\. +. .SS "\fBsearch\fR [\fIoptions\fR] [\fItext\fR|\fB/\fR\fItext\fR\fB/\fR]" Perform a substring search of cask tokens and formula names for \fItext\fR\. If \fItext\fR is flanked by slashes, it is interpreted as a regular expression\. The search for \fItext\fR is extended online to \fBhomebrew/core\fR and \fBhomebrew/cask\fR\. .