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.



38
39
40
41
42
# File 'lib/rbcli-tool/generators.rb', line 38

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

#runObject



44
45
46
47
48
49
50
# File 'lib/rbcli-tool/generators.rb', line 44

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