Method code for $command_lib.validate_command_template()

[Turn on line numbering]
arg str;
var cmd, tmp, loc, types, part, relations;

[tmp, types] = str.explode_delimited("<", ">");
loc = [];
cmd = [];
relations = #[];
for part in (tmp) {
    if (type(part) == 'string)
        cmd += part.explode();
    else
        cmd += [part];
}

// clean
for part in [1 .. cmd.length()] {
    if (type(cmd[part]) == 'string) {
        cmd = cmd.replace(part, cmd[part].trim());
    } else {
        relations = relations.add(part - 1, (> .get_argument_type(types[cmd[part]]) <));
        cmd = cmd.replace(part, "*");
    }
}
cmd = [cmd[1], cmd.subrange(2).join()];
if ((| "* *" in cmd[2] |))
    throw(~parse, "Invalid template: two args cannot be next to each other (<> <>)");
return [cmd, relations];

// Created 27-Mar-1995 as a part of ColdCore, see: @help Credit

Tlon