Class: Cask::Cmd::Create Private
- Inherits:
-
AbstractCommand
- Object
- AbstractCommand
- Cask::Cmd::Create
- Defined in:
- Library/Homebrew/cask/cmd/create.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Implementation of the brew cask create
command.
Constant Summary
Constants inherited from AbstractCommand
Instance Attribute Summary
Attributes inherited from AbstractCommand
Class Method Summary collapse
- .description ⇒ Object private
- .max_named ⇒ Object private
- .min_named ⇒ Object private
- .template(cask_token) ⇒ Object private
Instance Method Summary collapse
-
#initialize ⇒ Create
constructor
private
A new instance of Create.
- #run ⇒ Object private
Methods inherited from AbstractCommand
abstract?, banner_args, banner_headline, command_name, help, parser, run, short_description, visible?
Methods included from Homebrew::Search
#query_regexp, #search_casks, #search_descriptions, #search_formulae, #search_taps
Constructor Details
#initialize ⇒ Create
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Create.
22 23 24 25 26 |
# File 'Library/Homebrew/cask/cmd/create.rb', line 22 def initialize(*) super rescue Homebrew::CLI::MaxNamedArgumentsError raise UsageError, "Only one cask can be created at a time." end |
Class Method Details
.description ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 19 20 |
# File 'Library/Homebrew/cask/cmd/create.rb', line 18 def self.description "Creates the given <cask> and opens it in an editor." end |
.max_named ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16 |
# File 'Library/Homebrew/cask/cmd/create.rb', line 14 def self.max_named 1 end |
.min_named ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 |
# File 'Library/Homebrew/cask/cmd/create.rb', line 10 def self.min_named :cask end |
.template(cask_token) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'Library/Homebrew/cask/cmd/create.rb', line 41 def self.template(cask_token) <<~RUBY cask "#{cask_token}" do version "" sha256 "" url "https://" name "" desc "" homepage "" app "" end RUBY end |
Instance Method Details
#run ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'Library/Homebrew/cask/cmd/create.rb', line 28 def run cask_token = args.named.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 |