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>
@ -127,22 +36,92 @@ module Homebrew
"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,17 +16,26 @@ module Homebrew
module_function module_function
def reinstall_args def reinstall_args
cask_only_options = [ Homebrew::CLI::Parser.new do
[:switch, "--cask", "--casks", { usage_banner <<~EOS
description: "Treat all named arguments as casks.", `reinstall` [<options>] <formula>|<cask>
}],
*Cask::Cmd::AbstractCommand::OPTIONS,
]
formula_only_options = [ Uninstall and then reinstall a <formula> or <cask> using the same options it was
[:switch, "--formula", "--formulae", { originally installed with, plus any appended options specific to a <formula>.
description: "Treat all named arguments as formulae.",
}], Unless `HOMEBREW_NO_INSTALL_CLEANUP` is set, `brew cleanup` will then be run for the
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 " \
"or a shell inside the temporary build directory."
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, "--formula", "--formulae", { description: "Treat all named arguments as formulae." }],
[:switch, "-s", "--build-from-source", { [:switch, "-s", "--build-from-source", {
description: "Compile <formula> from source even if a bottle is available.", description: "Compile <formula> from source even if a bottle is available.",
}], }],
@ -46,40 +55,23 @@ module Homebrew
env: :display_install_times, env: :display_install_times,
description: "Print install times for each formula at the end of the run.", description: "Print install times for each formula at the end of the run.",
}], }],
] ].each do |options|
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
`reinstall` [<options>] <formula>|<cask>
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.
EOS
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 "-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."
conflicts "--build-from-source", "--force-bottle"
formula_only_options.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,16 +12,28 @@ module Homebrew
module_function module_function
def upgrade_args def upgrade_args
cask_only_options = [ Homebrew::CLI::Parser.new do
[:switch, "--cask", "--casks", { usage_banner <<~EOS
description: "Treat all named arguments as casks. If no named arguments " \ `upgrade` [<options>] [<formula>|<cask>]
"are specified, upgrade only outdated casks.",
}],
*Cask::Cmd::AbstractCommand::OPTIONS,
*Cask::Cmd::Upgrade::OPTIONS,
]
formula_only_options = [ Upgrade outdated casks and outdated, unpinned formulae using the same options they were originally
installed with, plus any appended brew formula options. If <cask> or <formula> are specified,
upgrade only the given <cask> or <formula> kegs (unless they are pinned; see `pin`, `unpin`).
Unless `HOMEBREW_NO_INSTALL_CLEANUP` is set, `brew cleanup` will then be run for the
upgraded 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 "\
"or a shell inside the temporary build directory."
switch "-f", "--force",
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 "-n", "--dry-run",
description: "Show what would be upgraded, but do not actually upgrade anything."
[
[:switch, "--formula", "--formulae", { [:switch, "--formula", "--formulae", {
description: "Treat all named arguments as formulae. If no named arguments" \ description: "Treat all named arguments as formulae. If no named arguments" \
"are specified, upgrade only outdated formulae.", "are specified, upgrade only outdated formulae.",
@ -54,43 +66,25 @@ module Homebrew
env: :display_install_times, env: :display_install_times,
description: "Print install times for each formula at the end of the run.", description: "Print install times for each formula at the end of the run.",
}], }],
] ].each do |options|
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
`upgrade` [<options>] [<formula>|<cask>]
Upgrade outdated casks and outdated, unpinned formulae using the same options they were originally
installed with, plus any appended brew formula options. If <cask> or <formula> are specified,
upgrade only the given <cask> or <formula> kegs (unless they are pinned; see `pin`, `unpin`).
Unless `HOMEBREW_NO_INSTALL_CLEANUP` is set, `brew cleanup` will then be run for the
upgraded 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 "\
"or a shell inside the temporary build directory."
switch "-f", "--force",
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 "-n", "--dry-run",
description: "Show what would be upgraded, but do not actually upgrade anything."
conflicts "--build-from-source", "--force-bottle"
formula_only_options.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\.
. .