Class: Hako::CLI::Deploy

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

Instance Method Summary collapse

Instance Method Details

#parse!(argv) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/hako/cli.rb', line 68

def parse!(argv)
  @force = false
  @tag = 'latest'
  @dry_run = false
  @verbose = false
  parser.parse!(argv)
  @yaml_path = argv.first

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

#parserObject



82
83
84
85
86
87
88
89
90
91
# File 'lib/hako/cli.rb', line 82

def parser
  @parser ||= OptionParser.new do |opts|
    opts.banner = 'hako deploy [OPTIONS] FILE'
    opts.version = VERSION
    opts.on('-f', '--force', 'Run deployment even if nothing is changed') { @force = true }
    opts.on('-t', '--tag=TAG', 'Specify tag (default: latest)') { |v| @tag = v }
    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



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/hako/cli.rb', line 56

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)).deploy(force: @force, tag: @tag, dry_run: @dry_run)
end