Inline install, reinstall and upgrade options.

This commit is contained in:
Markus Reiter 2020-10-08 11:18:24 +02:00
parent d6b563e752
commit 10e3b63b7b
5 changed files with 158 additions and 187 deletions

View File

@ -18,97 +18,6 @@ module Homebrew
module_function module_function
def install_args 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 <compiler>, 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 <formula> 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` <formula>.",
}],
[:switch, "--HEAD", {
description: "If <formula> 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 <formula>, 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 Homebrew::CLI::Parser.new do
usage_banner <<~EOS usage_banner <<~EOS
`install` [<options>] <formula>|<cask> `install` [<options>] <formula>|<cask>
@ -120,29 +29,99 @@ module Homebrew
the installed formulae or, every 30 days, for all formulae. the installed formulae or, every 30 days, for all formulae.
EOS EOS
switch "-d", "--debug", 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." "or a shell inside the temporary build directory."
switch "-f", "--force", 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." "non-migrated versions. Overwrite existing files when installing casks."
switch "-v", "--verbose", switch "-v", "--verbose",
description: "Print the verification and postinstall steps." 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 <compiler>, 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 <formula> 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` <formula>.",
}],
[:switch, "--HEAD", {
description: "If <formula> 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" [:switch, "--build-bottle", {
description: "Prepare the formula for eventual bottling during installation, skipping any " \
formula_only_options.each do |*args, **options| "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 <formula>, 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) send(*args, **options)
conflicts "--cask", args.last conflicts "--cask", args.last
end end
formula_options 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) send(*args, **options)
conflicts "--formula", args.last conflicts "--formula", args.last
end end
cask_options cask_options
conflicts "--ignore-dependencies", "--only-dependencies"
conflicts "--build-from-source", "--build-bottle", "--force-bottle"
min_named :formula_or_cask min_named :formula_or_cask
end end
end end

View File

@ -16,38 +16,6 @@ module Homebrew
module_function module_function
def reinstall_args 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 <formula> from source even if a bottle is available.",
}],
[:switch, "-i", "--interactive", {
description: "Download and patch <formula>, 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 Homebrew::CLI::Parser.new do
usage_banner <<~EOS usage_banner <<~EOS
`reinstall` [<options>] <formula>|<cask> `reinstall` [<options>] <formula>|<cask>
@ -59,27 +27,51 @@ module Homebrew
reinstalled formulae or, every 30 days, for all formulae. reinstalled formulae or, every 30 days, for all formulae.
EOS EOS
switch "-d", "--debug", 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." "or a shell inside the temporary build directory."
switch "-f", "--force", 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." "non-migrated versions."
switch "-v", "--verbose", switch "-v", "--verbose",
description: "Print the verification and postinstall steps." description: "Print the verification and postinstall steps."
conflicts "--build-from-source", "--force-bottle" [
[:switch, "--formula", "--formulae", { description: "Treat all named arguments as formulae." }],
formula_only_options.each do |options| [:switch, "-s", "--build-from-source", {
description: "Compile <formula> from source even if a bottle is available.",
}],
[:switch, "-i", "--interactive", {
description: "Download and patch <formula>, 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) send(*options)
conflicts "--cask", options[-2] conflicts "--cask", options[-2]
end end
formula_options 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) send(*options)
conflicts "--formula", options[-2] conflicts "--formula", options[-2]
end end
cask_options cask_options
conflicts "--build-from-source", "--force-bottle"
min_named :formula_or_cask min_named :formula_or_cask
end end
end end

View File

@ -12,50 +12,6 @@ module Homebrew
module_function module_function
def upgrade_args 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 <formula> from source even if a bottle is available.",
}],
[:switch, "-i", "--interactive", {
description: "Download and patch <formula>, 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 Homebrew::CLI::Parser.new do
usage_banner <<~EOS usage_banner <<~EOS
`upgrade` [<options>] [<formula>|<cask>] `upgrade` [<options>] [<formula>|<cask>]
@ -77,20 +33,58 @@ module Homebrew
description: "Print the verification and postinstall steps." description: "Print the verification and postinstall steps."
switch "-n", "--dry-run", switch "-n", "--dry-run",
description: "Show what would be upgraded, but do not actually upgrade anything." 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 <formula> from source even if a bottle is available.",
}],
[:switch, "-i", "--interactive", {
description: "Download and patch <formula>, 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" }],
[:switch, "--ignore-pinned", {
formula_only_options.each do |options| 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) send(*options)
conflicts "--cask", options[-2] conflicts "--cask", options[-2]
end end
formula_options 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) send(*options)
conflicts "--formula", options[-2] conflicts "--formula", options[-2]
end end
cask_options cask_options
conflicts "--build-from-source", "--force-bottle"
end end
end end

View File

@ -497,6 +497,8 @@ reinstalled formulae or, every 30 days, for all formulae.
Require all casks to have a checksum. Require all casks to have a checksum.
* `--[no-]quarantine`: * `--[no-]quarantine`:
Disable/enable quarantining of downloads. Default: enabled Disable/enable quarantining of downloads. Default: enabled
* `--skip-cask-deps`:
Skip installing cask dependencies.
### `search` [*`options`*] [*`text`*|`/`*`text`*`/`] ### `search` [*`options`*] [*`text`*|`/`*`text`*`/`]

View File

@ -717,6 +717,10 @@ Require all casks to have a checksum\.
\fB\-\-[no\-]quarantine\fR \fB\-\-[no\-]quarantine\fR
Disable/enable quarantining of downloads\. Default: enabled 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]" .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\. 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\.
. .