mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Merge pull request #1900 from H3rnand3zzz/enhancement/better-aliases
Add params support for aliases
This commit is contained in:
commit
06644915c3
@ -1643,12 +1643,13 @@ static const struct cmd_t command_defs[] = {
|
|||||||
"Add, remove or list command aliases.")
|
"Add, remove or list command aliases.")
|
||||||
CMD_ARGS(
|
CMD_ARGS(
|
||||||
{ "list", "List all aliases." },
|
{ "list", "List all aliases." },
|
||||||
{ "add <name> <value>", "Add a new command alias." },
|
{ "add <name> <value>", "Add a new command alias. The alias name must not contain any space characters." },
|
||||||
{ "remove <name>", "Remove a command alias." })
|
{ "remove <name>", "Remove a command alias." })
|
||||||
CMD_EXAMPLES(
|
CMD_EXAMPLES(
|
||||||
"/alias add friends /who online friends",
|
"/alias add friends /who online friends",
|
||||||
"/alias add /q /quit",
|
"/alias add /q /quit",
|
||||||
"/alias add a /away \"I'm in a meeting.\"",
|
"/alias add urg /msg odin@valhalla.edda [URGENT]",
|
||||||
|
"/alias add afk /status set away \"Away From Keyboard\"",
|
||||||
"/alias remove q",
|
"/alias remove q",
|
||||||
"/alias list")
|
"/alias list")
|
||||||
},
|
},
|
||||||
|
@ -5091,6 +5091,10 @@ cmd_alias(ProfWin* window, const char* const command, gchar** args)
|
|||||||
cons_bad_cmd_usage(command);
|
cons_bad_cmd_usage(command);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
|
if (strchr(alias, ' ')) {
|
||||||
|
cons_bad_cmd_usage(command);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
char* alias_p = alias;
|
char* alias_p = alias;
|
||||||
GString* ac_value = g_string_new("");
|
GString* ac_value = g_string_new("");
|
||||||
if (alias[0] == '/') {
|
if (alias[0] == '/') {
|
||||||
@ -8565,15 +8569,20 @@ _cmd_execute_alias(ProfWin* window, const char* const inp, gboolean* ran)
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto_char char* alias = strdup(inp + 1);
|
auto_char char* alias = strdup(inp + 1);
|
||||||
auto_gchar gchar* value = prefs_get_alias(alias);
|
auto_gcharv char** alias_parts = g_strsplit(alias, " ", 2);
|
||||||
if (value) {
|
auto_gchar gchar* value = prefs_get_alias(alias_parts[0]);
|
||||||
*ran = TRUE;
|
|
||||||
gboolean result = cmd_process_input(window, value);
|
if (!value) {
|
||||||
return result;
|
*ran = FALSE;
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
*ran = FALSE;
|
char* params = alias_parts[1];
|
||||||
return TRUE;
|
auto_gchar gchar* full_cmd = params ? g_strdup_printf("%s %s", value, params) : g_strdup(value);
|
||||||
|
|
||||||
|
*ran = TRUE;
|
||||||
|
gboolean result = cmd_process_input(window, full_cmd);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper function for status change commands
|
// helper function for status change commands
|
||||||
|
Loading…
Reference in New Issue
Block a user