From dd1a9a1e504bb60d1ced98f2da874b9b6cb88a64 Mon Sep 17 00:00:00 2001 From: Viachaslau Khalikin Date: Sun, 18 Sep 2022 19:29:02 +0300 Subject: Fix handle cmd_plugins_uninstall without args Signed-off-by: Viachaslau Khalikin --- src/command/cmd_funcs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 5d3673bb..3e40a4ea 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -7117,7 +7117,8 @@ gboolean cmd_plugins_uninstall(ProfWin* window, const char* const command, gchar** args) { if (args[1] == NULL) { - return FALSE; + cons_show("Please specify plugin name, see /help plugins"); + return TRUE; } gboolean res = plugins_uninstall(args[1]); -- cgit 1.4.1-2-gfad0 From 45fa60e7e2a2fd0253387478d201218a38dac5a8 Mon Sep 17 00:00:00 2001 From: Viachaslau Khalikin Date: Sun, 18 Sep 2022 23:34:45 +0300 Subject: Print unloaded plugins which already installed Signed-off-by: Viachaslau Khalikin --- src/command/cmd_defs.c | 2 +- src/command/cmd_funcs.c | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 98a74314..37821221 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -2162,7 +2162,7 @@ static struct cmd_t command_defs[] = { "/plugins reload []", "/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 []", "Install a plugin, or all plugins found in a directory (recursive). And loads it/them." }, { "uninstall []", "Uninstall a plugin." }, diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 3e40a4ea..e8a10a8d 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -7258,14 +7258,25 @@ cmd_plugins(ProfWin* window, const char* const command, gchar** args) } } + GSList* unloaded_plugins = plugins_unloaded_list(); + 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); + } + GList* plugins = plugins_loaded_list(); if (plugins == NULL) { - cons_show("No plugins installed."); + cons_show("No loaded plugins."); return TRUE; } GList* curr = plugins; - cons_show("Installed plugins:"); + cons_show("Loaded plugins:"); while (curr) { cons_show(" %s", curr->data); curr = g_list_next(curr); -- cgit 1.4.1-2-gfad0 From 6cb6823aed960ddbe7aaefaaeeb0980afb5735f3 Mon Sep 17 00:00:00 2001 From: Viachaslau Khalikin Date: Mon, 19 Sep 2022 00:45:29 +0300 Subject: Fix typo which catched by codespell --- src/command/cmd_defs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 37821221..91346fce 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -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 [text]", "Set user mood to with an optional [text]. Use /mood set to toggle through predfined moods." }, + { "set [text]", "Set user mood to with an optional [text]. Use /mood set to toggle through predefined moods." }, { "clear", "Clear your user mood." }) CMD_EXAMPLES( "/mood set happy \"So happy to use Profanity!\"", -- cgit 1.4.1-2-gfad0 From cc7231a43b45eb6e119df42ee64c195dc12b43a1 Mon Sep 17 00:00:00 2001 From: Viachaslau Khalikin Date: Mon, 19 Sep 2022 18:08:54 +0300 Subject: minor: using cons_bad_cmd_usage() instead of the manual handling Signed-off-by: Viachaslau Khalikin --- src/command/cmd_funcs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index e8a10a8d..16d4d4c0 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -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,7 @@ gboolean cmd_plugins_uninstall(ProfWin* window, const char* const command, gchar** args) { if (args[1] == NULL) { - cons_show("Please specify plugin name, see /help plugins"); + cons_bad_cmd_usage(command); return TRUE; } -- cgit 1.4.1-2-gfad0 From 0ceb8c53c314734c4db4231f47397f228da77081 Mon Sep 17 00:00:00 2001 From: Viachaslau Khalikin Date: Tue, 20 Sep 2022 01:46:51 +0300 Subject: fix: filtering of the available global plugins For command /plugins : Don't print files that do not correspond to the plugins design Signed-off-by: Viachaslau Khalikin --- src/command/cmd_funcs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 16d4d4c0..10f64d54 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -7247,14 +7247,16 @@ 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); } } -- cgit 1.4.1-2-gfad0 From d75e5c1c2859b287410c747c2ab4896f2880d3e6 Mon Sep 17 00:00:00 2001 From: Viachaslau Khalikin Date: Tue, 20 Sep 2022 04:00:44 +0300 Subject: add: autocompletion plugins arguments support for "update" and "uninstall" Signed-off-by: Viachaslau Khalikin --- src/command/cmd_ac.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index e3661cac..9dc855de 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -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(); -- cgit 1.4.1-2-gfad0 From 0cb46460b38ba122787550235874d512be816c42 Mon Sep 17 00:00:00 2001 From: Viachaslau Khalikin Date: Tue, 20 Sep 2022 04:30:11 +0300 Subject: fix: print when no plugins installed Signed-off-by: Viachaslau Khalikin --- src/command/cmd_funcs.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 10f64d54..e8322214 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -7260,7 +7260,14 @@ cmd_plugins(ProfWin* window, const char* const command, gchar** args) } } + GList* plugins = plugins_loaded_list(); GSList* unloaded_plugins = plugins_unloaded_list(); + + if (plugins == NULL && unloaded_plugins == NULL) { + cons_show("No plugins installed."); + return TRUE; + } + if (unloaded_plugins) { GSList* curr = unloaded_plugins; cons_show("The following plugins already installed and can be loaded:"); @@ -7271,19 +7278,15 @@ cmd_plugins(ProfWin* window, const char* const command, gchar** args) g_slist_free_full(unloaded_plugins, g_free); } - GList* plugins = plugins_loaded_list(); - if (plugins == NULL) { - cons_show("No loaded plugins."); - return TRUE; - } - - GList* curr = plugins; - cons_show("Loaded plugins:"); - while (curr) { - cons_show(" %s", curr->data); - curr = g_list_next(curr); + 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; } -- cgit 1.4.1-2-gfad0