mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Merge pull request #1755 from vinegret/fix/plugins_managment
Fix plugins managment
This commit is contained in:
commit
338b9587bd
@ -961,6 +961,8 @@ cmd_ac_init(void)
|
||||
|
||||
plugins_ac = autocomplete_new();
|
||||
autocomplete_add(plugins_ac, "install");
|
||||
autocomplete_add(plugins_ac, "update");
|
||||
autocomplete_add(plugins_ac, "uninstall");
|
||||
autocomplete_add(plugins_ac, "load");
|
||||
autocomplete_add(plugins_ac, "unload");
|
||||
autocomplete_add(plugins_ac, "reload");
|
||||
@ -2754,6 +2756,10 @@ _plugins_autocomplete(ProfWin* window, const char* const input, gboolean previou
|
||||
return cmd_ac_complete_filepath(input, "/plugins install", previous);
|
||||
}
|
||||
|
||||
if (strncmp(input, "/plugins update ", 16) == 0) {
|
||||
return cmd_ac_complete_filepath(input, "/plugins update", previous);
|
||||
}
|
||||
|
||||
if (strncmp(input, "/plugins load ", 14) == 0) {
|
||||
if (plugins_load_ac == NULL) {
|
||||
plugins_load_ac = autocomplete_new();
|
||||
|
@ -2162,7 +2162,7 @@ static struct cmd_t command_defs[] = {
|
||||
"/plugins reload [<plugin>]",
|
||||
"/plugins python_version")
|
||||
CMD_DESC(
|
||||
"Manage plugins. Passing no arguments lists currently loaded plugins and global plugins which are available for local installation. Global directory for Python plugins is " GLOBAL_PYTHON_PLUGINS_PATH " and for C Plugins is " GLOBAL_C_PLUGINS_PATH ".")
|
||||
"Manage plugins. Passing no arguments lists installed plugins and global plugins which are available for local installation. Global directory for Python plugins is " GLOBAL_PYTHON_PLUGINS_PATH " and for C Plugins is " GLOBAL_C_PLUGINS_PATH ".")
|
||||
CMD_ARGS(
|
||||
{ "install [<path>]", "Install a plugin, or all plugins found in a directory (recursive). And loads it/them." },
|
||||
{ "uninstall [<plugin>]", "Uninstall a plugin." },
|
||||
@ -2729,7 +2729,7 @@ static struct cmd_t command_defs[] = {
|
||||
"Set your mood (XEP-0107).")
|
||||
CMD_ARGS(
|
||||
{ "on|off", "Enable or disable displaying the mood of other users. On by default."},
|
||||
{ "set <mood> [text]", "Set user mood to <mood> with an optional [text]. Use /mood set <tab> to toggle through predfined moods." },
|
||||
{ "set <mood> [text]", "Set user mood to <mood> with an optional [text]. Use /mood set <tab> to toggle through predefined moods." },
|
||||
{ "clear", "Clear your user mood." })
|
||||
CMD_EXAMPLES(
|
||||
"/mood set happy \"So happy to use Profanity!\"",
|
||||
|
@ -6984,7 +6984,7 @@ cmd_plugins_install(ProfWin* window, const char* const command, gchar** args)
|
||||
char* path = NULL;
|
||||
|
||||
if (args[1] == NULL) {
|
||||
cons_show("Please provide a path to the plugin file or directory, see /help plugins");
|
||||
cons_bad_cmd_usage(command);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -7068,7 +7068,7 @@ cmd_plugins_update(ProfWin* window, const char* const command, gchar** args)
|
||||
char* path;
|
||||
|
||||
if (args[1] == NULL) {
|
||||
cons_show("Please provide a path to the plugin file, see /help plugins");
|
||||
cons_bad_cmd_usage(command);
|
||||
return TRUE;
|
||||
} else {
|
||||
path = get_expanded_path(args[1]);
|
||||
@ -7117,7 +7117,8 @@ gboolean
|
||||
cmd_plugins_uninstall(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
if (args[1] == NULL) {
|
||||
return FALSE;
|
||||
cons_bad_cmd_usage(command);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean res = plugins_uninstall(args[1]);
|
||||
@ -7246,30 +7247,46 @@ cmd_plugins(ProfWin* window, const char* const command, gchar** args)
|
||||
const gchar* filename;
|
||||
cons_show("The following Python plugins are available globally and can be installed:");
|
||||
while ((filename = g_dir_read_name(global_pyp_dir))) {
|
||||
cons_show(" %s", filename);
|
||||
if (g_str_has_suffix(filename, ".py"))
|
||||
cons_show(" %s", filename);
|
||||
}
|
||||
}
|
||||
if (global_cp_dir) {
|
||||
const gchar* filename;
|
||||
cons_show("The following C plugins are available globally and can be installed:");
|
||||
while ((filename = g_dir_read_name(global_cp_dir))) {
|
||||
cons_show(" %s", filename);
|
||||
if (g_str_has_suffix(filename, ".so"))
|
||||
cons_show(" %s", filename);
|
||||
}
|
||||
}
|
||||
|
||||
GList* plugins = plugins_loaded_list();
|
||||
if (plugins == NULL) {
|
||||
GSList* unloaded_plugins = plugins_unloaded_list();
|
||||
|
||||
if (plugins == NULL && unloaded_plugins == NULL) {
|
||||
cons_show("No plugins installed.");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GList* curr = plugins;
|
||||
cons_show("Installed plugins:");
|
||||
while (curr) {
|
||||
cons_show(" %s", curr->data);
|
||||
curr = g_list_next(curr);
|
||||
if (unloaded_plugins) {
|
||||
GSList* curr = unloaded_plugins;
|
||||
cons_show("The following plugins already installed and can be loaded:");
|
||||
while (curr) {
|
||||
cons_show(" %s", curr->data);
|
||||
curr = g_slist_next(curr);
|
||||
}
|
||||
g_slist_free_full(unloaded_plugins, g_free);
|
||||
}
|
||||
|
||||
if (plugins) {
|
||||
GList* curr = plugins;
|
||||
cons_show("Loaded plugins:");
|
||||
while (curr) {
|
||||
cons_show(" %s", curr->data);
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
g_list_free(plugins);
|
||||
}
|
||||
g_list_free(plugins);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user