From 10e3b63b7b7135a3e69f83b753285a566db738ac Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 8 Oct 2020 11:18:24 +0200 Subject: [PATCH] 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\. .