Class: RBCliTool::Command

Inherits:
Generator show all
Defined in:
lib/rbcli-tool/generators.rb

Instance Method Summary collapse

Methods inherited from Generator

inherited

Constructor Details

#initialize(root_path, template_vars) ⇒ Command

Returns a new instance of Command.



18
19
20
21
22
# File 'lib/rbcli-tool/generators.rb', line 18

def initialize root_path, template_vars
	@srcpath = "#{File.dirname(__FILE__)}/../../skeletons/project/application/commands/command.erb"
	@dest = "#{root_path}/application/commands/#{template_vars[:name]}.rb"
	@template_vars = template_vars
end

Instance Method Details

#run ⇒ Object



24
25
26
27
28
29
30
# File 'lib/rbcli-tool/generators.rb', line 24

def run
	if File.exists? @dest
		RBCliTool.continue_confirmation "The command #{@template_vars[:name]} already exists; contents will be overwritten."
		FileUtils.rm_rf @dest
	end
	RBCliTool.cp_file @srcpath, @dest, @template_vars
end