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

View File

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

View File

@ -45,6 +45,8 @@ module Homebrew
"(binaries and symlinks are excluded, unless originally from the same cask)." "(binaries and symlinks are excluded, unless originally from the same cask)."
switch "-v", "--verbose", switch "-v", "--verbose",
description: "Print the verification and postinstall steps." 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", { [:switch, "--formula", "--formulae", {
description: "Treat all named arguments as formulae.", description: "Treat all named arguments as formulae.",
@ -193,6 +195,7 @@ module Homebrew
skip_cask_deps: args.skip_cask_deps?, skip_cask_deps: args.skip_cask_deps?,
quarantine: args.quarantine?, quarantine: args.quarantine?,
quiet: args.quiet?, quiet: args.quiet?,
dry_run: args.dry_run?,
) )
end end