Class: Kdeploy::CLI

Inherits:
Thor
  • Object
show all
Extended by:
DSL
Defined in:
lib/kdeploy/cli.rb

Overview

Command-line interface for Kdeploy

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DSL

add_explicit_hosts, add_role_hosts, assign_task, build_package_command, create_task_block, directory, extended, file, get_task_hosts, host, hosts, include_tasks, included, inventory, kdeploy_hosts, kdeploy_roles, kdeploy_tasks, normalize_hosts_option, normalize_roles_option, package, role, roles, run, service, sync, task, task_empty?, tasks, template, upload, upload_template

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/kdeploy/cli.rb', line 15

def self.exit_on_failure?
  true
end

Instance Method Details

#execute(task_file, task_name = nil) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/kdeploy/cli.rb', line 54

def execute(task_file, task_name = nil)
  load_config_file
  show_banner_once
  @task_file_dir = File.dirname(File.expand_path(task_file))
  load_task_file(task_file)

  tasks_to_run = determine_tasks(task_name)
  all_results = execute_tasks(tasks_to_run)

  # Exit non-zero if any executed host failed.
  exit 1 if any_failed?(all_results)
rescue StandardError => e
  puts Kdeploy::Banner.show_error(e.message)
  exit 1
end

#help(command = nil) ⇒ Object



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

def help(command = nil)
  if command
    super
  else
    show_general_help
  end
end

#init(dir = '.') ⇒ Object



37
38
39
40
41
42
43
# File 'lib/kdeploy/cli.rb', line 37

def init(dir = '.')
  initializer = Initializer.new(dir)
  initializer.run
rescue StandardError => e
  puts Kdeploy::Banner.show_error(e.message)
  exit 1
end

#versionObject



23
24
25
# File 'lib/kdeploy/cli.rb', line 23

def version
  puts Kdeploy::Banner.show_version
end