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



115
116
117
118
119
120
121
122
123
124
125
# File 'lib/hako/cli.rb', line 115

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

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

#parserObject



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

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



103
104
105
106
107
108
109
110
111
112
113
# File 'lib/hako/cli.rb', line 103

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

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

  Commander.new(Application.new(@yaml_path)).rollback(dry_run: @dry_run)
end