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
|
# File 'lib/ezgit/commands.rb', line 28
def process
@cmd = ARGV.shift
matched = false
@all.each do |current|
if current[:name].to_s.eql? @cmd
matched = true
@cmd_opts = Trollop::options do
usage = current[:usage]
usage ||= "ezgit #{current[:name].to_s} [<options>]"
banner <<-HELP_DESCRIPTION
command: ezgit #{current[:name].to_s}\n
#{current[:help].to_s}
Usage:
#{usage}
options are:
HELP_DESCRIPTION
current[:options].each do |cmd_opt|
sym = cmd_opt[0]
info = cmd_opt[1]
flags = cmd_opt[2]
opt sym, info, flags
end
end
current[:action].call(@cmd_opts, ARGV)
break
end
end
Trollop::die "unknown subcommand #{@cmd.inspect}" if not matched
if $commands.options[:debug]
puts "Global options: #{$commands.options.inspect}"
puts "Subcommand: #{@cmd.inspect}"
puts "Subcommand options: #{@cmd_opts.inspect}"
puts "Remaining arguments: #{ARGV.inspect}"
end
end
|