Class: Engineyard::Recipes::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/engineyard-recipes/cli.rb

Instance Method Summary collapse

Instance Method Details

#clone(folder_path) ⇒ Object

TODO support git URIs



76
77
78
79
80
81
82
83
84
# File 'lib/engineyard-recipes/cli.rb', line 76

def clone(folder_path) # TODO support git URIs
  require 'engineyard-recipes/generators/local_recipe_clone_generator'
  generator = Engineyard::Recipes::Generators::LocalRecipeCloneGenerator
  _, recipe_name = FetchUri.fetch_recipe(folder_path, generator.source_root, options["name"])
  generator.start([recipe_name])
  
rescue Engineyard::Recipes::FetchUri::UnknownPath => e
  error "No recipe found at #{e.message}"
end

#definition(recipe_name, definition_name) ⇒ Object



61
62
63
64
# File 'lib/engineyard-recipes/cli.rb', line 61

def definition(recipe_name, definition_name)
  require 'engineyard-recipes/generators/definition_generator'
  Engineyard::Recipes::Generators::DefinitionGenerator.start([recipe_name, definition_name])
end

#gem(recipe_name) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/engineyard-recipes/cli.rb', line 52

def gem(recipe_name)
  recipe_type ||= options["helper"] ? "helper" : "recipe"
  repo_name ||= options["repo"] || "eycloud-#{recipe_type}-#{recipe_name}"

  require 'engineyard-recipes/generators/gem_generator'
  Engineyard::Recipes::Generators::GemGenerator.start([recipe_name, repo_name, recipe_type])
end

#initObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/engineyard-recipes/cli.rb', line 14

def init
  on_deploy    = options["on-deploy"] || false
  bundled_chef = options["chef"] || false
  
  if bundled_chef
    require 'engineyard-recipes/generators/init_bundled_chef_generator'
    Engineyard::Recipes::Generators::InitGenerator.start([{:on_deploy => on_deploy}])
  else
    require 'engineyard-recipes/generators/init_resin_chef_generator'
    Engineyard::Recipes::Generators::InitGenerator.start([{:on_deploy => on_deploy}])
  end
  init_sm if options[:sm]
end

#init_smObject



29
30
31
32
# File 'lib/engineyard-recipes/cli.rb', line 29

def init_sm
  require 'engineyard-recipes/generators/init_sm_generator'
  Engineyard::Recipes::Generators::InitSmGenerator.start
end

#package(recipe_name) ⇒ Object



38
39
40
41
42
43
44
45
46
47
# File 'lib/engineyard-recipes/cli.rb', line 38

def package(recipe_name)
  package  = options["package"] || "UNKNOWN/#{recipe_name}"
  version  = options["version"] || '1.0.0'
  unmasked = options["unmasked"] || false
  
  require 'engineyard-recipes/generators/package_generator'
  Engineyard::Recipes::Generators::PackageGenerator.start([
    recipe_name, package, version, {:unmasked => unmasked}
  ])
end

#sm(uri, *commands) ⇒ Object



88
89
90
91
92
93
# File 'lib/engineyard-recipes/cli.rb', line 88

def sm(uri, *commands)
  require 'engineyard-recipes/generators/sm_generator'
  recipe_name = options["name"]
  
  Engineyard::Recipes::Generators::SmGenerator.start([recipe_name, uri, commands])
end

#timezone(timezone) ⇒ Object



67
68
69
70
71
72
# File 'lib/engineyard-recipes/cli.rb', line 67

def timezone(timezone)
  require 'engineyard-recipes/generators/timezone_generator'
  Engineyard::Recipes::Generators::TimezoneGenerator.start([timezone])
rescue Engineyard::Recipes::Generators::TimezoneGenerator::InvalidTimezone => e
  error "#{e.message} is not a known timezone."
end

#versionObject



96
97
98
99
# File 'lib/engineyard-recipes/cli.rb', line 96

def version
  require 'engineyard-recipes/version'
  shell.say Engineyard::Recipes::VERSION
end