Class: TerminalRunner

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

Constant Summary collapse

@@avail_options =
[]
@@avail_params =
[]
@@name =
""

Class Method Summary collapse

Class Method Details

.runObject


76
77
78
# File 'lib/terrun.rb', line 76

def self.run
  puts "Override self.run to start."
end

.start(args) ⇒ Object


42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/terrun.rb', line 42

def self.start(args)
  @@params = {}
  @@options = {}

  @@avail_params.each do |param|
    param.value = args.shift
    @@params[param.name] = param.value
    if param.value.nil?
      puts "** Missing value for #{param.name} **"
      show_usage
      exit
    end
  end

  until args.empty?
    option = []
    option_name = get_next_arg(args)
    unless option_details = find_option(option_name)
      puts "Unknown option: '#{option_name}'."
      exit
    end
    (0..option_details.arg_num).each do |i|
      option[i] = args.shift
      if option[i].nil?
        puts "Missing argument for option '#{option_name}'"
        exit
      end
    end
    @@options[option_name] = option
  end

  self.run
end