Class: Cask::Cmd::Create

Inherits:
AbstractCommand show all
Defined in:
brew/Library/Homebrew/cask/cmd/create.rb

Instance Attribute Summary

Attributes inherited from AbstractCommand

#args

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractCommand

abstract?, command_name, run, visible

Methods included from Homebrew::Search

#query_regexp, #search_casks, #search_descriptions, #search_formulae, #search_taps

Methods included from Options

#process_arguments

Constructor Details

#initializeCreate

Returns a new instance of Create



6
7
8
9
10
# File 'brew/Library/Homebrew/cask/cmd/create.rb', line 6

def initialize(*)
  super
  raise CaskUnspecifiedError if args.empty?
  raise ArgumentError, "Only one Cask can be created at a time." if args.count > 1
end

Class Method Details

.helpObject



40
41
42
# File 'brew/Library/Homebrew/cask/cmd/create.rb', line 40

def self.help
  "creates the given Cask and opens it in an editor"
end

.template(cask_token) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'brew/Library/Homebrew/cask/cmd/create.rb', line 25

def self.template(cask_token)
  <<~RUBY
    cask '#{cask_token}' do
      version ''
      sha256 ''

      url "https://"
      name ''
      homepage ''

      app ''
    end
  RUBY
end

Instance Method Details

#runObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'brew/Library/Homebrew/cask/cmd/create.rb', line 12

def run
  cask_token = args.first
  cask_path = CaskLoader.path(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

  exec_editor cask_path
end