# File lib/cri/base.rb, line 96 def command_named(name) # Find by exact name or alias command = @commands.find { |c| c.name == name or c.aliases.include?(name) } return command unless command.nil? # Find by approximation commands = @commands.select { |c| c.name[0, name.length] == name } if commands.length > 1 $stderr.puts "#{@tool_name}: '#{name}' is ambiguous:" $stderr.puts " #{commands.map { |c| c.name }.join(' ') }" exit 1 elsif commands.length == 0 $stderr.puts "#{@tool_name}: unknown command '#{name}'\n" show_help exit 1 else return commands[0] end end