Class: BuckKnife::ProjectNew

Inherits:
Chef::Knife
  • Object
show all
Defined in:
lib/chef/knife/project_new.rb

Instance Method Summary collapse

Instance Method Details

#runObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/chef/knife/project_new.rb', line 11

def run
  project_name = @name_args[0]

  if project_name.nil?
    show_usage
    ui.fatal("You must specify a project name")
    exit 1
  end

  template = BuckKnife.template_root.join("project.json.erb").read
  compiled = ERB.new(template, nil, '%>').result(binding)
  project_path = Project.root.join("#{project_name}.json")
  project_path.open("w") { |f| f.write compiled }

  ui.output ui.color("#{project_name}.json written to #{project_path}", :green)
end