Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reinstall command #4193

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions doc/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# CHANGELOG

## 0.34.0

* __Casks__
- 19 Casks added (42 updated) by 39 contributors since 0.33.1
- 1460 total Casks
* __Features__
- [#2427][] Give the user help on checksum errors
- [#4169][] automatically transition to new Tap name/location
- [#4163][] update all references to new caskroom org home
* __Fixes__
- none
* __Documentation__
- none
* __Breaking Changes__
- The repository has moved under the Caskroom organization. We expect this to
be a seamless transition for users.

[#2427]: https://github.com/caskroom/homebrew-cask/issues/2427
[#4169]: https://github.com/caskroom/homebrew-cask/issues/4169
[#4163]: https://github.com/caskroom/homebrew-cask/issues/4163

## 0.33.1

* __Casks__
Expand Down
4 changes: 4 additions & 0 deletions doc/man/brew-cask.1
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ Install \fICask\fR\.
Uninstall \fICask\fR\.
.
.TP
\fBreinstall\fR \fICask\fR
Reinstall \fICask\fR\.
.
.TP
\fBsearch\fR \fItext\fR | /\fIregexp\fR/
Perform a substring search of Cask names for \fItext\fR\. If the text is delimited by slashes, it is interpreted as a Ruby regular expression\.
.
Expand Down
3 changes: 3 additions & 0 deletions doc/src/brew-cask.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ names, and other aspects of this manual are still subject to change.
* `uninstall` or `rm` or `remove` <Cask>:
Uninstall <Cask>.

* `reinstall` <Cask>:
Reinstall <Cask>.

* `search` or `-S`:
Display all Casks available for install.

Expand Down
1 change: 1 addition & 0 deletions lib/cask/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Cask::CLI; end
require 'cask/cli/info'
require 'cask/cli/install'
require 'cask/cli/list'
require 'cask/cli/reinstall'
require 'cask/cli/search'
require 'cask/cli/uninstall'
require 'cask/cli/update'
Expand Down
30 changes: 30 additions & 0 deletions lib/cask/cli/reinstall.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class Cask::CLI::Reinstall
def self.run(*args)
raise CaskUnspecifiedError if args.empty?
cask_names = args.reject { |a| a.chars.first == '-' }
force = args.include? '--force'
cask_names.each do |cask_name|
odebug "Reinstalling Cask #{cask_name}"
cask = Cask.load(cask_name)
begin
if cask
Cask::Installer.new(cask).uninstall
end
Cask::Installer.new(cask).install(force)
rescue CaskUnavailableError => e
exact_match, partial_matches, search_term = Cask::CLI::Search.search(cask_name)
errmsg = "#{cask_name}"
if exact_match
errmsg.concat(". Did you mean:\n#{exact_match}")
elsif !partial_matches.empty?
errmsg.concat(". Did you mean one of:\n#{stringify_columns(partial_matches.take(20))}\n")
end
raise CaskUnavailableError.new(errmsg)
end
end
end

def self.help
"reinstalls the cask of the given name"
end
end
2 changes: 1 addition & 1 deletion lib/cask/version.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
HOMEBREW_CASK_VERSION = '0.33.1'
HOMEBREW_CASK_VERSION = '0.34.0'