Class: Jara::Cli

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

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Cli

Returns a new instance of Cli.



8
9
10
11
# File 'lib/jara/cli.rb', line 8

def initialize(argv)
  @command = argv.first
  @argv = argv.drop(1)
end

Instance Method Details

#runObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/jara/cli.rb', line 13

def run
  parse_argv(@argv)
  options = {}
  options[:archiver] = @archiver if @archiver
  options[:build_command] = @build_command if @build_command
  options[:branch] = @branch if @branch
  releaser = Jara::Releaser.new(@environment, @bucket, options)
  case @command
  when /help|-h/
    $stderr.puts(option_parser)
  when 'release'
    releaser.release
  when 'build'
    releaser.build_artifact
  else
    $stderr.puts('Unknown command "%s", expected "build" or "release"' % @command)
    exit(1)
  end
rescue OptionParser::ParseError => e
  $stderr.puts(option_parser)
  exit(1)
rescue JaraError => e
  $stderr.puts(sprintf('Could not %s artifact: %s', @command, e.message))
  exit(1)
end