0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 23:44:01 +01:00

modules/console: Add shortcut convenience by expanding sigils to apropos cmds.

This commit is contained in:
Jason Volk 2020-08-22 16:47:51 -07:00
parent e17307de13
commit 6ff608c065

View file

@ -265,6 +265,24 @@ console_command_derived(opt &out, const string_view &line)
if(lex_castable<int>(id))
return console_command_numeric(out, line);
// Branch if the line starts with just a sigil (but not an identifier).
// In this case we'll expand the sigil to its name as a convenience for
// the apropos command suite.
if(m::has_sigil(id) && size(id) == 1)
{
char lower_buf[16];
const fmt::snstringf expanded_line
{
size(line) + 16, "%s %s",
tolower(lower_buf, reflect(m::sigil(id))),
tokens_after(line, ' ', 0),
};
return _console_command(out, expanded_line);
}
// Branch if the line starts with an identifier; identifiers are
// themselves convenience commands.
if(m::has_sigil(id)) switch(m::sigil(id))
{
case m::id::EVENT: