Module: ARGVEXT

Defined in:
lib/argv/cms.rb,
lib/argv/ext.rb

Defined Under Namespace

Modules: EXTENSION

Class Method Summary collapse

Class Method Details

.add_help_msg(msg, *keys) ⇒ Object



5
6
7
8
9
# File 'lib/argv/cms.rb', line 5

def add_help_msg msg,*keys
  raise unless msg.class <= String
  @@help_msg_obj.push [msg,keys]
  return nil
end

.help_msgObject Also known as: show_help



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/argv/cms.rb', line 11

def help_msg

  helper_sym= [:helper,:help,:h]
  self.add_help_msg "This will show you the help msg (this)",*helper_sym
  unless ::ARGV.sym_flags.select{ |e| helper_sym.include?(e) }.empty?

    tmp_ary= []
    @@help_msg_obj.each{ |ary|
      tmp_ary.push(ary[0])
      ary[1].each{|e| tmp_ary.push( ( e.to_s.length == 1 ? "-#{e}" : "--#{e}" ) )}
      tmp_ary.push("")
    }

    tmp_ary.each{ |element| element.include?('--') ? element.gsub!('--',"\t--") : element.gsub!('-',"\t -")}
    puts "",tmp_ary.join("\n"),""
    Process.exit!

  end
end