Method code for $command_cache.match_remote_command()

[Turn off line numbering]
  1: arg str, cmd, args;
  2: var command, m, matched, templates, info, cdef, def, cmds, c;
  3: 
  4: if (this() != $remote_cache)
  5:     throw(~perm, "This should only be used on $remote_cache");
  6: templates = (matched = []);
  7: if (commands && dict_contains(commands, cmd))
  8:     cmds = commands[cmd];
  9: else
 10:     return 0;
 11: for command in (cmds) {
 12:     if (!(info = command[2].command_info('remote, command[1])))
 13:         continue;
 14:     for cdef in (info) {
 15:         if ((m = match_template(args, cdef[2])) != 0)
 16:             matched += [[listlen(m), command[2], [str, cmd, @m], @sublist(cdef, 3)]];
 17:     }
 18:     templates = union(templates, info.slice(3));
 19:     refresh();
 20: }
 21: if (matched)
 22:     return ['remote, matched];
 23: if (!templates)
 24:     return 0;
 25: return ['partial, templates];

// Created 18-Sep-1997 as a part of ColdCore, see: @help Credit

Tlon