class Itamae::CLI
Constants
- GENERATE_TARGETS
Public Class Methods
define_exec_options()
click to toggle source
# File lib/itamae/cli.rb, line 19 def self.define_exec_options option :recipe_graph, type: :string, desc: "[EXPERIMENTAL] Write recipe dependency graph in DOT", banner: "PATH" option :node_json, type: :string, aliases: ['-j'] option :node_yaml, type: :string, aliases: ['-y'] option :dry_run, type: :boolean, aliases: ['-n'] option :shell, type: :string, default: "/bin/sh" option :ohai, type: :boolean, default: false, desc: "This option is DEPRECATED and will be unavailable." option :profile, type: :string, desc: "[EXPERIMENTAL] Save profiling data", banner: "PATH" option :detailed_exitcode, type: :boolean, default: false, desc: "exit code 0 - The run succeeded with no changes or failures, exit code 1 - The run failed, exit code 2 - The run succeeded, and some resources were changed" end
new(*)
click to toggle source
Calls superclass method
# File lib/itamae/cli.rb, line 12 def initialize(*) super Itamae.logger.level = ::Logger.const_get(options[:log_level].upcase) Itamae.logger.formatter.colored = options[:color] end
Public Instance Methods
destroy(target, name)
click to toggle source
# File lib/itamae/cli.rb, line 98 def destroy(target, name) validate_generate_target!('destroy', target) generator = Generators.find(target).new generator.destination_root = File.join("#{target}s", name) generator.remove_files end
docker(*recipe_files)
click to toggle source
# File lib/itamae/cli.rb, line 66 def docker(*recipe_files) if recipe_files.empty? raise "Please specify recipe files." end run(recipe_files, :docker, options) end
generate(target, name)
click to toggle source
# File lib/itamae/cli.rb, line 88 def generate(target, name) validate_generate_target!('generate', target) generator = Generators.find(target).new generator.destination_root = File.join("#{target}s", name) generator.copy_files end
init(name)
click to toggle source
# File lib/itamae/cli.rb, line 80 def init(name) generator = Generators::Project.new generator.destination_root = name generator.invoke_all end
local(*recipe_files)
click to toggle source
# File lib/itamae/cli.rb, line 32 def local(*recipe_files) if recipe_files.empty? raise "Please specify recipe files." end run(recipe_files, :local, options) end
ssh(*recipe_files)
click to toggle source
# File lib/itamae/cli.rb, line 49 def ssh(*recipe_files) if recipe_files.empty? raise "Please specify recipe files." end unless options[:host] || options[:vagrant] raise "Please set '-h <hostname>' or '--vagrant'" end run(recipe_files, :ssh, options) end
version()
click to toggle source
# File lib/itamae/cli.rb, line 75 def version puts "Itamae v#{Itamae::VERSION}" end
Private Instance Methods
options()
click to toggle source
Calls superclass method
# File lib/itamae/cli.rb, line 107 def options @itamae_options ||= super.dup.tap do |options| if config = options[:config] options.merge!(YAML.load_file(config)) end end end
run(recipe_files, backend_type, options)
click to toggle source
# File lib/itamae/cli.rb, line 123 def run(recipe_files, backend_type, options) runner = Runner.run(recipe_files, backend_type, options) if options[:detailed_exitcode] && runner.diff? exit 2 end end
validate_generate_target!(command, target)
click to toggle source
# File lib/itamae/cli.rb, line 115 def validate_generate_target!(command, target) unless GENERATE_TARGETS.include?(target) msg = %Q!ERROR: "itamae #{command}" was called with "#{target}" ! msg << "but expected to be in #{GENERATE_TARGETS.inspect}" fail InvocationError, msg end end