Class: Kdeploy::CLI

Inherits:
Thor
  • Object
show all
Extended by:
DSL
Defined in:
lib/kdeploy/cli/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)


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

def self.exit_on_failure?
  true
end

Instance Method Details

#execute(task_file, task_name = nil) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/kdeploy/cli/cli.rb', line 60

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



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

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

#init(dir = '.') ⇒ Object



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

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

#versionObject



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

def version
  puts Kdeploy::Banner.show_version
end