mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Added /script run
This commit is contained in:
parent
ea4fb2ce6c
commit
0769fc6b1b
@ -1691,6 +1691,28 @@ static struct cmd_t command_defs[] =
|
||||
"/xa",
|
||||
"/xa This meeting is going to be a long one")
|
||||
},
|
||||
|
||||
{ "/script",
|
||||
cmd_script, parse_args, 2, 2, NULL,
|
||||
CMD_NOTAGS
|
||||
CMD_SYN(
|
||||
"/script run <script>",
|
||||
"/script remove <script>",
|
||||
"/script list",
|
||||
"/script show <script>")
|
||||
CMD_DESC(
|
||||
"Manage and run command scripts. "
|
||||
"Scripts are stored in $XDG_DATA_HOME/profanity/scripts/ which is usually $HOME/.local/share/profanity/scripts/.")
|
||||
CMD_ARGS(
|
||||
{ "script run <script>", "Execute a script." },
|
||||
{ "script remove <script>", "Remove a script TODO." },
|
||||
{ "script list", "List all scripts TODO." },
|
||||
{ "script show <script>", "Show the commands in script TODO." })
|
||||
CMD_EXAMPLES(
|
||||
"/script list",
|
||||
"/script run myscript",
|
||||
"/script show somescript")
|
||||
},
|
||||
};
|
||||
|
||||
static Autocomplete commands_ac;
|
||||
@ -1755,6 +1777,7 @@ static Autocomplete pgp_ac;
|
||||
static Autocomplete pgp_log_ac;
|
||||
static Autocomplete tls_ac;
|
||||
static Autocomplete tls_certpath_ac;
|
||||
static Autocomplete script_ac;
|
||||
|
||||
/*
|
||||
* Initialise command autocompleter and history
|
||||
@ -2175,6 +2198,12 @@ cmd_init(void)
|
||||
tls_certpath_ac = autocomplete_new();
|
||||
autocomplete_add(tls_certpath_ac, "set");
|
||||
autocomplete_add(tls_certpath_ac, "clear");
|
||||
|
||||
script_ac = autocomplete_new();
|
||||
autocomplete_add(script_ac, "run");
|
||||
autocomplete_add(script_ac, "list");
|
||||
autocomplete_add(script_ac, "remove");
|
||||
autocomplete_add(script_ac, "show");
|
||||
}
|
||||
|
||||
void
|
||||
@ -2242,6 +2271,7 @@ cmd_uninit(void)
|
||||
autocomplete_free(pgp_log_ac);
|
||||
autocomplete_free(tls_ac);
|
||||
autocomplete_free(tls_certpath_ac);
|
||||
autocomplete_free(script_ac);
|
||||
}
|
||||
|
||||
gboolean
|
||||
@ -2426,6 +2456,7 @@ cmd_reset_autocomplete(ProfWin *window)
|
||||
autocomplete_reset(pgp_log_ac);
|
||||
autocomplete_reset(tls_ac);
|
||||
autocomplete_reset(tls_certpath_ac);
|
||||
autocomplete_reset(script_ac);
|
||||
|
||||
if (window->type == WIN_CHAT) {
|
||||
ProfChatWin *chatwin = (ProfChatWin*)window;
|
||||
@ -2638,8 +2669,8 @@ _cmd_complete_parameters(ProfWin *window, const char * const input)
|
||||
}
|
||||
}
|
||||
|
||||
gchar *cmds[] = { "/prefs", "/disco", "/close", "/subject", "/room" };
|
||||
Autocomplete completers[] = { prefs_ac, disco_ac, close_ac, subject_ac, room_ac };
|
||||
gchar *cmds[] = { "/prefs", "/disco", "/close", "/subject", "/room", "/script" };
|
||||
Autocomplete completers[] = { prefs_ac, disco_ac, close_ac, subject_ac, room_ac, script_ac };
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(cmds); i++) {
|
||||
result = autocomplete_param_with_ac(input, cmds[i], completers[i], TRUE);
|
||||
|
@ -49,6 +49,7 @@
|
||||
#include "config/preferences.h"
|
||||
#include "config/theme.h"
|
||||
#include "config/tlscerts.h"
|
||||
#include "config/scripts.h"
|
||||
#include "contact.h"
|
||||
#include "roster_list.h"
|
||||
#include "jid.h"
|
||||
@ -689,6 +690,21 @@ cmd_account(ProfWin *window, const char * const command, gchar **args)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
cmd_script(ProfWin *window, const char * const command, gchar **args)
|
||||
{
|
||||
if ((g_strcmp0(args[0], "run") == 0) && args[1]) {
|
||||
gboolean res = scripts_exec(args[1]);
|
||||
if (!res) {
|
||||
cons_show("Could not find script %s", args[1]);
|
||||
}
|
||||
} else {
|
||||
cons_bad_cmd_usage(command);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
cmd_sub(ProfWin *window, const char * const command, gchar **args)
|
||||
{
|
||||
|
@ -149,6 +149,7 @@ gboolean cmd_time(ProfWin *window, const char * const command, gchar **args);
|
||||
gboolean cmd_resource(ProfWin *window, const char * const command, gchar **args);
|
||||
gboolean cmd_inpblock(ProfWin *window, const char * const command, gchar **args);
|
||||
gboolean cmd_encwarn(ProfWin *window, const char * const command, gchar **args);
|
||||
gboolean cmd_script(ProfWin *window, const char * const command, gchar **args);
|
||||
|
||||
gboolean cmd_form_field(ProfWin *window, char *tag, gchar **args);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user