Class: Builtins::Init

Inherits:
Builtin show all
Defined in:
lib/builtins/init.rb

Constant Summary collapse

OPS_YML =
"ops.yml"
TEMPLATE_DIR =
File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "etc"))
OPS_YML_TEMPLATE =
File.join(TEMPLATE_DIR, "%<template_name>s.template.yml")
DEFAULT_TEMPLATE_NAME =
"ops"

Instance Attribute Summary

Attributes inherited from Builtin

#args, #config

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Builtin

class_for, #initialize

Constructor Details

This class inherits a constructor from Builtin

Class Method Details

.descriptionObject



16
17
18
# File 'lib/builtins/init.rb', line 16

def description
	"creates an ops.yml file from a template"
end

Instance Method Details

#runObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/builtins/init.rb', line 21

def run
	if File.exist?(OPS_YML)
		Output.error("File '#{OPS_YML} exists; not initializing.")
	else
		Output.out("Creating '#{OPS_YML} from template...")
		FileUtils.cp(template_path, OPS_YML)
	end
rescue SystemCallError
	Output.error(template_not_found_message)
	exit 1
end