Class: Kitchen::CLI

Inherits:
Thor
  • Object
show all
Includes:
PerformCommand, Logging
Defined in:
lib/kitchen/cli.rb

Overview

The command line runner for Kitchen.

Author:

Defined Under Namespace

Modules: PerformCommand

Constant Summary collapse

MAX_CONCURRENCY =

The maximum number of concurrent instances that can run–which is a bit high

9999

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PerformCommand

#perform

Methods included from Logging

#banner, #debug, #error, #fatal, #info, #warn

Constructor Details

#initialize(*args) ⇒ CLI

Constructs a new instance.


65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/kitchen/cli.rb', line 65

def initialize(*args)
  super
  $stdout.sync = true
  @loader = Kitchen::Loader::YAML.new(
    project_config: ENV["KITCHEN_YAML"] || ENV["KITCHEN_YML"],
    local_config: ENV["KITCHEN_LOCAL_YAML"] || ENV["KITCHEN_LOCAL_YML"],
    global_config: ENV["KITCHEN_GLOBAL_YAML"] || ENV["KITCHEN_GLOBAL_YML"]
  )
  @config = Kitchen::Config.new(
    loader: @loader
  )
  @config.log_level = Kitchen.env_log unless Kitchen.env_log.nil?
  @config.log_overwrite = Kitchen.env_log_overwrite unless Kitchen.env_log_overwrite.nil?
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config


62
63
64
# File 'lib/kitchen/cli.rb', line 62

def config
  @config
end

Class Method Details

.log_optionsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Sets the logging method_options


82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/kitchen/cli.rb', line 82

def self.log_options
  method_option :log_level,
    aliases: "-l",
    desc: "Set the log level (debug, info, warn, error, fatal)"
  method_option :log_overwrite,
    desc: "Set to false to prevent log overwriting each time Test Kitchen runs",
    type: :boolean
  method_option :color,
    type: :boolean,
    lazy_default: $stdout.tty?,
    desc: "Toggle color output for STDOUT logger"
end

.test_base_pathObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Sets the test_base_path method_options


97
98
99
100
101
# File 'lib/kitchen/cli.rb', line 97

def self.test_base_path
  method_option :test_base_path,
    aliases: "-t",
    desc: "Set the base path of the tests"
end

Instance Method Details

#consoleObject


299
300
301
# File 'lib/kitchen/cli.rb', line 299

def console
  perform("console", "console")
end

#diagnose(*args) ⇒ Object


139
140
141
142
# File 'lib/kitchen/cli.rb', line 139

def diagnose(*args)
  update_config!
  perform("diagnose", "diagnose", args, loader: @loader)
end

#doctor(*args) ⇒ Object


271
272
273
274
# File 'lib/kitchen/cli.rb', line 271

def doctor(*args)
  update_config!
  perform("doctor", "doctor", args)
end

#exec(*args) ⇒ Object


282
283
284
285
# File 'lib/kitchen/cli.rb', line 282

def exec(*args)
  update_config!
  perform("exec", "exec", args)
end

#list(*args) ⇒ Object


117
118
119
120
# File 'lib/kitchen/cli.rb', line 117

def list(*args)
  update_config!
  perform("list", "list", args)
end

#login(*args) ⇒ Object


254
255
256
257
# File 'lib/kitchen/cli.rb', line 254

def (*args)
  update_config!
  perform("login", "login", args)
end

#package(*args) ⇒ Object


261
262
263
264
# File 'lib/kitchen/cli.rb', line 261

def package(*args)
  update_config!
  perform("package", "package", args)
end

#sinkObject


294
295
296
# File 'lib/kitchen/cli.rb', line 294

def sink
  perform("sink", "sink")
end

#test(*args) ⇒ Object


246
247
248
249
250
# File 'lib/kitchen/cli.rb', line 246

def test(*args)
  update_config!
  ensure_initialized
  perform("test", "test", args)
end

#versionObject


288
289
290
# File 'lib/kitchen/cli.rb', line 288

def version
  puts "Test Kitchen version #{Kitchen::VERSION}"
end