Module: Gat::Help

Included in:
Base
Defined in:
lib/gat/help.rb

Instance Method Summary collapse

Instance Method Details

#gatget_helpObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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
# File 'lib/gat/help.rb', line 27

def gatget_help

  help_message =  "\n Help: \n"
  help_message << " ------\n\n"
  help_message << " # #{ 'launcher name'.ljust(31) } : #{ $0 }\n"
  help_message << " # #{ 'launcher class'.ljust(31) } : #{ self.class.name }\n"
  help_message << " # #{ 'gatget name'.ljust(31) } : #{ self.name.camelize }\n"
  help_message << " # #{ 'description'.ljust(31) } : #{ self.config['description'] || '<gatget description not avalilable>' }\n"

  if self.config['operations'].nil? or self.config['operations'].is_a?(String)
    help_message << " # no operations defined\n"
  else
    help_message << " # operations\n"

    self.config['operations'].each_pair do |op_key, op_data|
      help_message   << " #{ ' ' * 5 } * #{ op_key.ljust(25)   } : #{ op_data['description'] || '< no description avalilable >' } \n\n"
      syntax_message =  " #{ ' ' * 9 } $ > #{ $0 } #{ op_key } "
      argument_message = ''
  
      if op_data['arguments'] and op_data['arguments'].any?
  
        if self.config['arguments'].nil?
          raise GatgetConfigException.new("Global arguments not defined in yml", 'gatget_help')
        end
  
        op_data['arguments'].each do |argument|
        syntax_message << "<#{ argument }> "
        unless self.config['arguments'][argument].nil?
          argument_data = self.config['arguments'][argument]['description'] || '<no description available>'
        argument_message << "\n #{ ' ' * 9 } | #{ "<#{ argument }>".ljust(21) } : #{ argument_data } "
        else
          raise GatgetConfigException.new("argument '#{argument}' not defined", 'gatget_help')
        end
        end
      end
      help_message << syntax_message
      help_message << argument_message
      help_message << "\n\n\n"
    end
  end
  help_message << "Gat Version #{ Gat::VERSION }"
  

  $stdout.puts help_message
end

#returning(value) {|value| ... } ⇒ Object

Yields:

  • (value)


73
74
75
76
# File 'lib/gat/help.rb', line 73

def returning(value)
   yield(value)
  value
end