Implementing ask input with casks
renamed `ask` to `ask_formulae` moving option `--ask` to work with formulae and casks
This commit is contained in:
parent
5013c17474
commit
f875dbc8a7
@ -43,6 +43,10 @@ module Homebrew
|
|||||||
description: "Print the verification and post-install steps."
|
description: "Print the verification and post-install steps."
|
||||||
switch "-n", "--dry-run",
|
switch "-n", "--dry-run",
|
||||||
description: "Show what would be installed, but do not actually install anything."
|
description: "Show what would be installed, but do not actually install anything."
|
||||||
|
switch "--ask",
|
||||||
|
env: :ask,
|
||||||
|
description: "Ask for confirmation before downloading and installing formulae. " \
|
||||||
|
"Print bottles and dependencies download size and install size."
|
||||||
[
|
[
|
||||||
[:switch, "--formula", "--formulae", {
|
[:switch, "--formula", "--formulae", {
|
||||||
description: "Treat all named arguments as formulae.",
|
description: "Treat all named arguments as formulae.",
|
||||||
@ -123,11 +127,6 @@ module Homebrew
|
|||||||
[:switch, "--overwrite", {
|
[:switch, "--overwrite", {
|
||||||
description: "Delete files that already exist in the prefix while linking.",
|
description: "Delete files that already exist in the prefix while linking.",
|
||||||
}],
|
}],
|
||||||
[:switch, "--ask", {
|
|
||||||
description: "Ask for confirmation before downloading and installing formulae. " \
|
|
||||||
"Print bottles and dependencies download size and install size.",
|
|
||||||
env: :ask,
|
|
||||||
}],
|
|
||||||
].each do |args|
|
].each do |args|
|
||||||
options = args.pop
|
options = args.pop
|
||||||
send(*args, **options)
|
send(*args, **options)
|
||||||
@ -218,7 +217,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
if casks.any?
|
if casks.any?
|
||||||
opoo "Option --ask is not compatible with casks." if args.options_only.include? "--ask"
|
Install.ask_casks casks if args.ask?
|
||||||
if args.dry_run?
|
if args.dry_run?
|
||||||
if (casks_to_install = casks.reject(&:installed?).presence)
|
if (casks_to_install = casks.reject(&:installed?).presence)
|
||||||
ohai "Would install #{::Utils.pluralize("cask", casks_to_install.count, include_count: true)}:"
|
ohai "Would install #{::Utils.pluralize("cask", casks_to_install.count, include_count: true)}:"
|
||||||
@ -311,7 +310,7 @@ module Homebrew
|
|||||||
Install.perform_preinstall_checks_once
|
Install.perform_preinstall_checks_once
|
||||||
Install.check_cc_argv(args.cc)
|
Install.check_cc_argv(args.cc)
|
||||||
|
|
||||||
Install.ask(formulae, args: args) if args.ask?
|
Install.ask_formulae(formulae, args: args) if args.ask?
|
||||||
|
|
||||||
Install.install_formulae(
|
Install.install_formulae(
|
||||||
installed_formulae,
|
installed_formulae,
|
||||||
|
|||||||
@ -39,6 +39,10 @@ module Homebrew
|
|||||||
"non-migrated versions."
|
"non-migrated versions."
|
||||||
switch "-v", "--verbose",
|
switch "-v", "--verbose",
|
||||||
description: "Print the verification and post-install steps."
|
description: "Print the verification and post-install steps."
|
||||||
|
switch "--ask",
|
||||||
|
description: "Ask for confirmation before downloading and upgrading formulae. " \
|
||||||
|
"Print bottles and dependencies download size, install and net install size.",
|
||||||
|
env: :ask
|
||||||
[
|
[
|
||||||
[:switch, "--formula", "--formulae", { description: "Treat all named arguments as formulae." }],
|
[:switch, "--formula", "--formulae", { description: "Treat all named arguments as formulae." }],
|
||||||
[:switch, "-s", "--build-from-source", {
|
[:switch, "-s", "--build-from-source", {
|
||||||
@ -63,11 +67,6 @@ module Homebrew
|
|||||||
[:switch, "-g", "--git", {
|
[:switch, "-g", "--git", {
|
||||||
description: "Create a Git repository, useful for creating patches to the software.",
|
description: "Create a Git repository, useful for creating patches to the software.",
|
||||||
}],
|
}],
|
||||||
[:switch, "--ask", {
|
|
||||||
description: "Ask for confirmation before downloading and upgrading formulae. " \
|
|
||||||
"Print bottles and dependencies download size, install and net install size.",
|
|
||||||
env: :ask,
|
|
||||||
}],
|
|
||||||
].each do |args|
|
].each do |args|
|
||||||
options = args.pop
|
options = args.pop
|
||||||
send(*args, **options)
|
send(*args, **options)
|
||||||
@ -132,7 +131,7 @@ module Homebrew
|
|||||||
Install.perform_preinstall_checks_once
|
Install.perform_preinstall_checks_once
|
||||||
|
|
||||||
# If asking the user is enabled, show dependency and size information.
|
# If asking the user is enabled, show dependency and size information.
|
||||||
Install.ask(formulae, args: args) if args.ask?
|
Install.ask_formulae(formulae, args: args) if args.ask?
|
||||||
|
|
||||||
formulae.each do |formula|
|
formulae.each do |formula|
|
||||||
if formula.pinned?
|
if formula.pinned?
|
||||||
@ -173,6 +172,9 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
if casks.any?
|
if casks.any?
|
||||||
|
if args.ask?
|
||||||
|
Install.ask_casks casks
|
||||||
|
end
|
||||||
Cask::Reinstall.reinstall_casks(
|
Cask::Reinstall.reinstall_casks(
|
||||||
*casks,
|
*casks,
|
||||||
binaries: args.binaries?,
|
binaries: args.binaries?,
|
||||||
|
|||||||
@ -39,7 +39,11 @@ module Homebrew
|
|||||||
description: "Print the verification and post-install steps."
|
description: "Print the verification and post-install 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 "--ask",
|
||||||
|
description: "Ask for confirmation before downloading and upgrading formulae. " \
|
||||||
|
"Print bottles and dependencies download size, install and net install size.",
|
||||||
|
env: :ask
|
||||||
|
[
|
||||||
[: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.",
|
||||||
@ -71,11 +75,6 @@ module Homebrew
|
|||||||
[:switch, "--overwrite", {
|
[:switch, "--overwrite", {
|
||||||
description: "Delete files that already exist in the prefix while linking.",
|
description: "Delete files that already exist in the prefix while linking.",
|
||||||
}],
|
}],
|
||||||
[:switch, "--ask", {
|
|
||||||
description: "Ask for confirmation before downloading and upgrading formulae. " \
|
|
||||||
"Print bottles and dependencies download size, install and net install size.",
|
|
||||||
env: :ask,
|
|
||||||
}],
|
|
||||||
].each do |args|
|
].each do |args|
|
||||||
options = args.pop
|
options = args.pop
|
||||||
send(*args, **options)
|
send(*args, **options)
|
||||||
@ -222,7 +221,7 @@ module Homebrew
|
|||||||
Install.perform_preinstall_checks_once
|
Install.perform_preinstall_checks_once
|
||||||
|
|
||||||
# Main block: if asking the user is enabled, show dependency and size information.
|
# Main block: if asking the user is enabled, show dependency and size information.
|
||||||
Install.ask(formulae_to_install, args: args) if args.ask?
|
Install.ask_formulae(formulae_to_install, args: args) if args.ask?
|
||||||
|
|
||||||
Upgrade.upgrade_formulae(
|
Upgrade.upgrade_formulae(
|
||||||
formulae_to_install,
|
formulae_to_install,
|
||||||
@ -261,6 +260,7 @@ module Homebrew
|
|||||||
sig { params(casks: T::Array[Cask::Cask]).returns(T::Boolean) }
|
sig { params(casks: T::Array[Cask::Cask]).returns(T::Boolean) }
|
||||||
def upgrade_outdated_casks(casks)
|
def upgrade_outdated_casks(casks)
|
||||||
return false if args.formula?
|
return false if args.formula?
|
||||||
|
Install.ask_casks casks
|
||||||
|
|
||||||
Cask::Upgrade.upgrade_casks(
|
Cask::Upgrade.upgrade_casks(
|
||||||
*casks,
|
*casks,
|
||||||
|
|||||||
@ -331,8 +331,8 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
# If asking the user is enabled, show dependency and size information.
|
# If asking the user is enabled, show dependency and size information.
|
||||||
def ask(formulae, args:)
|
def ask_formulae(formulae, args:)
|
||||||
return if formulae.empty?
|
return if formulae.empty? && casks.empty?
|
||||||
|
|
||||||
ohai "Looking for bottles..."
|
ohai "Looking for bottles..."
|
||||||
|
|
||||||
@ -348,6 +348,15 @@ module Homebrew
|
|||||||
ask_input
|
ask_input
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def ask_casks(casks)
|
||||||
|
return if casks.empty?
|
||||||
|
|
||||||
|
puts "#{::Utils.pluralize("Cask", casks.count, plural: "s")} \
|
||||||
|
(#{casks.count}): #{casks.join(", ")}\n\n"
|
||||||
|
|
||||||
|
ask_input
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def perform_preinstall_checks(all_fatal: false)
|
def perform_preinstall_checks(all_fatal: false)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user