From 6cb1afa246c4b2814632c5453b74bbc9d132792f Mon Sep 17 00:00:00 2001 From: phinze Date: Sat, 13 Apr 2013 14:17:00 -0500 Subject: [PATCH] add unlinkapps for cli access to revert linkapps --- lib/cask/cli/unlinkapps.rb | 12 ++++++++++++ test/cli/unlinkapps_test.rb | 24 ++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 lib/cask/cli/unlinkapps.rb create mode 100644 test/cli/unlinkapps_test.rb diff --git a/lib/cask/cli/unlinkapps.rb b/lib/cask/cli/unlinkapps.rb new file mode 100644 index 000000000..00d097e3a --- /dev/null +++ b/lib/cask/cli/unlinkapps.rb @@ -0,0 +1,12 @@ +class Cask::CLI::Unlinkapps + def self.run(*args) + casks_to_link = args.empty? ? Cask.installed : args + casks_to_link.each do |cask_name| + Cask::AppLinker.new(Cask.load(cask_name)).unlink + end + end + + def self.help + "removes symlinks from cask-installed .app files from ~/Applications" + end +end diff --git a/test/cli/unlinkapps_test.rb b/test/cli/unlinkapps_test.rb new file mode 100644 index 000000000..3c8dab3e6 --- /dev/null +++ b/test/cli/unlinkapps_test.rb @@ -0,0 +1,24 @@ +require 'test_helper' + +describe Cask::CLI::Unlinkapps do + before do + shutup do + # use CLI so both casks start installed and linked + Cask::CLI::Install.run('local-caffeine', 'local-transmission') + end + end + + it "only unlinks casks mentioned when arguments are provided" do + Cask::CLI::Unlinkapps.run('local-transmission') + + (Cask.appdir/"Transmission.app").wont_be :symlink? + (Cask.appdir/"Caffeine.app").must_be :symlink? + end + + it "unlinks all installed casks when no arguments supplied" do + Cask::CLI::Unlinkapps.run + + (Cask.appdir/"Transmission.app").wont_be :symlink? + (Cask.appdir/"Caffeine.app").wont_be :symlink? + end +end