# File lib/hammer_cli/completer.rb, line 178 def find_last_cmd(line) cmd = @command subcommands = sub_command_map(cmd) # if the last word is not complete we have to select it's parent # -> shorten the line words = line.dup words.pop unless line.complete? cmd_idx = 0 words.each_with_index do |word, idx| unless word.start_with?('-') break unless subcommands.has_key? word cmd = subcommands[word].subcommand_class cmd_idx = idx+1 subcommands = sub_command_map(cmd) end end # cut processed part of the line and return remaining remaining = line.dup remaining.shift(cmd_idx) if cmd_idx > 0 return [cmd, remaining] end