Class: Kdeploy::CLI
- Inherits:
-
Thor
- Object
- Thor
- Kdeploy::CLI
- Defined in:
- lib/kdeploy/cli.rb
Overview
Command Line Interface for kdeploy
Constant Summary collapse
- SCRIPT_OPTIONS =
Common options for commands that execute scripts
{ config: { aliases: '-c', desc: 'Configuration file path' }, inventory: { aliases: '-i', desc: 'Inventory file path' }, dry_run: { aliases: '-d', type: :boolean, desc: 'Perform dry run without executing' }, verbose: { aliases: '-v', type: :boolean, desc: 'Enable verbose output' }, log_file: { aliases: '-l', desc: 'Log file path' } }.freeze
Class Method Summary collapse
-
.exit_on_failure? ⇒ Boolean
Fix Thor deprecation warning.
Instance Method Summary collapse
- #config ⇒ Object
- #deploy(script_file) ⇒ Object
- #execute(script_file) ⇒ Object
- #help(command = nil) ⇒ Object
- #init(project_name = nil) ⇒ Object
- #stats(command = 'summary') ⇒ Object
- #validate(script_file) ⇒ Object
- #version ⇒ Object
Class Method Details
.exit_on_failure? ⇒ Boolean
Fix Thor deprecation warning
16 17 18 |
# File 'lib/kdeploy/cli.rb', line 16 def self.exit_on_failure? true end |
Instance Method Details
#config ⇒ Object
92 93 94 95 96 97 |
# File 'lib/kdeploy/cli.rb', line 92 def config setup_configuration display_configuration(Kdeploy.configuration) end |
#deploy(script_file) ⇒ Object
48 49 50 |
# File 'lib/kdeploy/cli.rb', line 48 def deploy(script_file) execute(script_file) end |
#execute(script_file) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/kdeploy/cli.rb', line 31 def execute(script_file) setup_configuration setup_logging validate_script_file(script_file) begin [:dry_run] ? perform_dry_run(script_file) : execute_script(script_file) rescue Kdeploy::Error => e handle_deployment_error(e) rescue StandardError => e handle_unexpected_error(e) end end |
#help(command = nil) ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/kdeploy/cli.rb', line 106 def help(command = nil) puts '' puts '📖 Available Commands:'.colorize(:yellow) puts '' if command super else display_available_commands end end |
#init(project_name = nil) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/kdeploy/cli.rb', line 54 def init(project_name = nil) project_name = determine_project_name(project_name) display_init_header(project_name) create_project_structure(project_name) display_init_success(project_name) end |
#stats(command = 'summary') ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/kdeploy/cli.rb', line 123 def stats(command = 'summary') case command.downcase when 'summary' show_summary_stats when 'deployments' show_deployment_stats when 'tasks' show_task_stats when 'failures' show_failure_stats when 'trends' show_trend_stats when 'global' show_global_stats when 'clear' clear_statistics when 'export' export_statistics else error "Unknown stats command: #{command}" puts '' puts 'Available commands: summary, deployments, tasks, failures, trends, global, clear, export' exit 1 end end |
#validate(script_file) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/kdeploy/cli.rb', line 66 def validate(script_file) setup_configuration display_validation_header(script_file) validate_script_file(script_file) begin pipeline = Kdeploy.load_script(script_file) validation_errors = pipeline.validate if validation_errors.empty? display_validation_success(pipeline) else display_validation_errors(validation_errors) end rescue Kdeploy::Error => e display_validation_failure(e) end end |
#version ⇒ Object
100 101 102 103 |
# File 'lib/kdeploy/cli.rb', line 100 def version display_version_info end |