diff options
| author | AnastasiaSulyagina | 2016-08-18 22:11:42 +0300 |
|---|---|---|
| committer | AnastasiaSulyagina | 2016-08-19 14:50:14 +0300 |
| commit | e81f4ab7deeb40308f240be5ea00091fc8786d7a (patch) | |
| tree | b5418f9149de71c0f05f90cb2b39ab47f46e27b4 /Library/Homebrew/cask/lib/hbc/cli/create.rb | |
| parent | 5c7c9de669025bbe4cad9829be39c5cf3b31ad25 (diff) | |
| download | brew-e81f4ab7deeb40308f240be5ea00091fc8786d7a.tar.bz2 | |
init
Diffstat (limited to 'Library/Homebrew/cask/lib/hbc/cli/create.rb')
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli/create.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/cli/create.rb b/Library/Homebrew/cask/lib/hbc/cli/create.rb new file mode 100644 index 000000000..3c1ac76ed --- /dev/null +++ b/Library/Homebrew/cask/lib/hbc/cli/create.rb @@ -0,0 +1,37 @@ +class Hbc::CLI::Create < Hbc::CLI::Base + def self.run(*args) + cask_tokens = cask_tokens_from(args) + raise Hbc::CaskUnspecifiedError if cask_tokens.empty? + cask_token = cask_tokens.first.sub(%r{\.rb$}i, "") + cask_path = Hbc.path(cask_token) + odebug "Creating Cask #{cask_token}" + + raise Hbc::CaskAlreadyCreatedError, cask_token if cask_path.exist? + + File.open(cask_path, "w") do |f| + f.write template(cask_token) + end + + exec_editor cask_path + end + + def self.template(cask_token) + <<-EOS.undent + cask '#{cask_token}' do + version '' + sha256 '' + + url 'https://' + name '' + homepage '' + license :unknown # TODO: change license and remove this comment; ':unknown' is a machine-generated placeholder + + app '' + end + EOS + end + + def self.help + "creates the given Cask and opens it in an editor" + end +end |
