Class: Mobilis::CommandLine

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

Class Method Summary collapse

Class Method Details

.parse_args(args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/mobilis/command_line.rb', line 5

def self.parse_args(args)
  options = {}
  Optimist.options(args) do
    banner "multi-project codebase generation toolkit"
    stop_on ["load", "build", "help"]
  end
  if args == []
    options[:subcommand] = :interactive
    return options
  end
  options[:subcommand] = args.shift.to_sym
  case options[:subcommand]
  when :load
    options[:filename] = args.shift
  when :build
    options[:filename] = args.shift
  when :help
    puts "I think we'd all like a little help."
  else
    Optimist::die "unknown subcommand #{cmd.inspect}"
  end
  options
end