Module: Mspire::Commandline

Defined in:
lib/mspire/commandline.rb

Constant Summary

SUB_COMMANDS =
{
  to_imzml: 'convert mzml to imzml',
}

Class Method Summary collapse

Class Method Details

.run(argv) ⇒ Object



10
11
12
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/mspire/commandline.rb', line 10

def self.run(argv)

  parser = Trollop::Parser.new do
    banner "usage: mspire <subcommand> [OPTIONS]"
    text ""
    text "subcommands: "
    SUB_COMMANDS.each do |k,v|
      text "  #{k}  #{v}"
    end
    text ""
    stop_on SUB_COMMANDS.keys.map(&:to_s)
  end

  begin 
    global_opts = parser.parse(argv)
  rescue Trollop::HelpNeeded
    parser.educate && exit 
  end

  parser.educate && exit unless argv.size > 0

  cmd = argv.shift
  cmd_parser = 
    case cmd.to_sym
    when :to_imzml
      Mspire::Imzml::Writer::Commandline.run(argv, global_opts)
    end
end