Class: Itamae::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/itamae/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, opts, config) ⇒ CLI

Returns a new instance of CLI.



9
10
11
12
13
14
15
# File 'lib/itamae/cli.rb', line 9

def initialize(args, opts, config)
  opts = Config.new(opts).load
  super(args, opts, config)

  Itamae.logger.level = ::Logger.const_get(options[:log_level].upcase)
  Itamae.logger.formatter.colored = options[:color]
end

Class Method Details

.define_exec_optionsObject



17
18
19
20
21
22
23
24
# File 'lib/itamae/cli.rb', line 17

def self.define_exec_options
  option :dot, type: :string, default: nil, desc: "Only write 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 inavailable."
end

Instance Method Details

#docker(*recipe_files) ⇒ Object



62
63
64
65
66
67
68
# File 'lib/itamae/cli.rb', line 62

def docker(*recipe_files)
  if recipe_files.empty?
    raise "Please specify recipe files."
  end

  Runner.run(recipe_files, :docker, options)
end

#local(*recipe_files) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/itamae/cli.rb', line 28

def local(*recipe_files)
  if recipe_files.empty?
    raise "Please specify recipe files."
  end

  Runner.run(recipe_files, :local, options)
end

#ssh(*recipe_files) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/itamae/cli.rb', line 45

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

  Runner.run(recipe_files, :ssh, options)
end

#versionObject



71
72
73
# File 'lib/itamae/cli.rb', line 71

def version
  puts "Itamae v#{Itamae::VERSION}"
end