Class: Hako::CLI::Rollback

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

Instance Method Summary collapse

Instance Method Details

#parse!(argv) ⇒ Object



127
128
129
130
131
132
133
134
135
136
137
# File 'lib/hako/cli.rb', line 127

def parse!(argv)
  @dry_run = false
  @verbose = false
  parser.parse!(argv)
  @definition_path = argv.first

  if @definition_path.nil?
    puts parser.help
    exit 1
  end
end

#parserObject



139
140
141
142
143
144
145
146
# File 'lib/hako/cli.rb', line 139

def parser
  @parser ||= OptionParser.new do |opts|
    opts.banner = 'hako rollback [OPTIONS] FILE'
    opts.version = VERSION
    opts.on('-n', '--dry-run', 'Enable dry-run mode') { @dry_run = true }
    opts.on('-v', '--verbose', 'Enable verbose logging') { @verbose = true }
  end
end

#run(argv) ⇒ Object



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/hako/cli.rb', line 109

def run(argv)
  parse!(argv)
  require 'hako/application'
  require 'hako/commander'

  if @verbose
    Hako.logger.level = Logger::DEBUG
  end

  options =
    if @dry_run
      { expand_variables: false, ask_keys: true }
    else
      {}
    end
  Commander.new(Application.new(@definition_path, options)).rollback(dry_run: @dry_run)
end