Method code for $command_cache.match_remote_command()

[Turn on line numbering]
arg str, cmd, args;
var command, m, matched, templates, info, cdef, def, cmds, c;

if (this() != $remote_cache)
    throw(~perm, "This should only be used on $remote_cache");
templates = (matched = []);
if (commands && dict_contains(commands, cmd))
    cmds = commands[cmd];
else
    return 0;
for command in (cmds) {
    if (!(info = command[2].command_info('remote, command[1])))
        continue;
    for cdef in (info) {
        if ((m = match_template(args, cdef[2])) != 0)
            matched += [[listlen(m), command[2], [str, cmd, @m], @sublist(cdef, 3)]];
    }
    templates = union(templates, info.slice(3));
    refresh();
}
if (matched)
    return ['remote, matched];
if (!templates)
    return 0;
return ['partial, templates];

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

Tlon