aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/lib/hbc/cli/create.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/create.rb
parentdebe4540e4ff76be80467a2bf32bfd32dbfc72eb (diff)
downloadbrew-df1864ee435c1c48f87344800d2e7cf055a12f93.tar.bz2
Add `CLI::Options` DSL.
Diffstat (limited to 'Library/Homebrew/cask/lib/hbc/cli/create.rb')
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/create.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/cli/create.rb b/Library/Homebrew/cask/lib/hbc/cli/create.rb
index dc8666b37..8de101092 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/create.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/create.rb
@@ -1,15 +1,18 @@
module Hbc
class CLI
class Create < 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?
- cask_token = cask_tokens.first.sub(/\.rb$/i, "")
+ cask_token = args.first
cask_path = CaskLoader.path(cask_token)
- odebug "Creating Cask #{cask_token}"
-
raise CaskAlreadyCreatedError, cask_token if cask_path.exist?
+ odebug "Creating Cask #{cask_token}"
File.open(cask_path, "w") do |f|
f.write self.class.template(cask_token)
end