add dry-run option to cask#install

This commit is contained in:
hyuraku 2022-08-15 21:48:57 +09:00
parent cc61a759ed
commit 93ebe42a72
3 changed files with 13 additions and 3 deletions

View File

@ -56,7 +56,8 @@ module Cask
require_sha: nil,
quarantine: nil,
quiet: nil,
zap: nil
zap: nil,
dry_run: nil
)
odie "Installing casks is supported only on macOS" unless OS.mac?
@ -69,6 +70,7 @@ module Cask
quarantine: quarantine,
quiet: quiet,
zap: zap,
dry_run: dry_run,
}.compact
options[:quarantine] = true if options[:quarantine].nil?

View File

@ -24,7 +24,7 @@ module Cask
skip_cask_deps: false, binaries: true, verbose: false,
zap: false, require_sha: false, upgrade: false,
installed_as_dependency: false, quarantine: true,
verify_download_integrity: true, quiet: false)
verify_download_integrity: true, quiet: false, dry_run: false)
@cask = cask
@command = command
@force = force
@ -39,11 +39,12 @@ module Cask
@quarantine = quarantine
@verify_download_integrity = verify_download_integrity
@quiet = quiet
@dry_run = dry_run
end
attr_predicate :binaries?, :force?, :skip_cask_deps?, :require_sha?,
:reinstall?, :upgrade?, :verbose?, :zap?, :installed_as_dependency?,
:quarantine?, :quiet?
:quarantine?, :quiet?, :dry_run?
def self.caveats(cask)
odebug "Printing caveats"
@ -96,6 +97,10 @@ module Cask
check_conflicts
print caveats
if dry_run?
puts "#{Formatter.identifier(@cask)} would be installed"
exit
end
fetch
uninstall_existing_cask if reinstall?

View File

@ -45,6 +45,8 @@ module Homebrew
"(binaries and symlinks are excluded, unless originally from the same cask)."
switch "-v", "--verbose",
description: "Print the verification and postinstall steps."
switch "-n", "--dry-run",
description: "Show what would be installed, but do not actually install anything."
[
[:switch, "--formula", "--formulae", {
description: "Treat all named arguments as formulae.",
@ -193,6 +195,7 @@ module Homebrew
skip_cask_deps: args.skip_cask_deps?,
quarantine: args.quarantine?,
quiet: args.quiet?,
dry_run: args.dry_run?,
)
end