aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/lib/hbc/cli/edit.rb
diff options
context:
space:
mode:
authorMarkus Reiter2017-05-21 00:15:56 +0200
committerMarkus Reiter2017-05-22 02:51:17 +0200
commitdf1864ee435c1c48f87344800d2e7cf055a12f93 (patch)
tree338018ac56614b5d2a8fe313fb8e1c0a36346032 /Library/Homebrew/cask/lib/hbc/cli/edit.rb
parentdebe4540e4ff76be80467a2bf32bfd32dbfc72eb (diff)
downloadbrew-df1864ee435c1c48f87344800d2e7cf055a12f93.tar.bz2
Add `CLI::Options` DSL.
Diffstat (limited to 'Library/Homebrew/cask/lib/hbc/cli/edit.rb')
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/edit.rb15
1 files changed, 10 insertions, 5 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/cli/edit.rb b/Library/Homebrew/cask/lib/hbc/cli/edit.rb
index d8ab3d9e0..dec0fe36b 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/edit.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/edit.rb
@@ -1,16 +1,21 @@
module Hbc
class CLI
class Edit < AbstractCommand
+ def initialize(*)
+ super
+ raise CaskUnspecifiedError if args.empty?
+ raise ArgumentError, "Only one Cask can be created at a time." if args.count > 1
+ end
+
def run
- cask_tokens = self.class.cask_tokens_from(@args)
- raise CaskUnspecifiedError if cask_tokens.empty?
- # only respects the first argument
- cask_token = cask_tokens.first.sub(/\.rb$/i, "")
+ cask_token = args.first
cask_path = CaskLoader.path(cask_token)
- odebug "Opening editor for Cask #{cask_token}"
+
unless cask_path.exist?
raise CaskUnavailableError, %Q(#{cask_token}, run "brew cask create #{cask_token}" to create a new Cask)
end
+
+ odebug "Opening editor for Cask #{cask_token}"
exec_editor cask_path
end