Class: Boshify::CommandLine

Inherits:
Object
  • Object
show all
Defined in:
lib/boshify/command_line.rb

Overview

Command line argument processing

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ CommandLine

Returns a new instance of CommandLine.



7
8
9
10
11
12
13
14
15
16
# File 'lib/boshify/command_line.rb', line 7

def initialize(options)
  unless options[:program_name]
    fail ArgumentError, 'Program name must be specified'
  end
  unless options[:package_converter]
    fail ArgumentError, 'Package converter must be specified'
  end
  @program_name = Pathname.new(options[:program_name]).basename
  @package_converter = options[:package_converter]
end

Instance Method Details

#run(args) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/boshify/command_line.rb', line 18

def run(args)
  with_options(args) do |options|
    begin
      use_mirror_if_specified(options[:mirror])
      @package_converter.create_release_for(name: options[:package])
      { exit_code: 0, stdout: "Package #{options[:package]} converted",
        stderr: '' }
    rescue => e
      { exit_code: 1, stdout: '', stderr: e.message }
    end
  end
end