summary refs log tree commit diff
path: root/pkgs/applications/networking/irc/weechat/aggregate-commands.patch
blob: 41e3c54a2d57e41ec03fc5b26f2162b7da9f2dc5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index 91c3c068d..8105e4171 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -8345,10 +8345,20 @@ command_exec_list (const char *command_list)
 void
 command_startup (int plugins_loaded)
 {
+    int i;
+
     if (plugins_loaded)
     {
         command_exec_list (CONFIG_STRING(config_startup_command_after_plugins));
-        command_exec_list (weechat_startup_commands);
+        if (weechat_startup_commands)
+        {
+            for (i = 0; i < weelist_size (weechat_startup_commands); i++)
+            {
+                command_exec_list (
+                    weelist_string (
+                        weelist_get (weechat_startup_commands, i)));
+            }
+        }
     }
     else
         command_exec_list (CONFIG_STRING(config_startup_command_before_plugins));
diff --git a/src/core/weechat.c b/src/core/weechat.c
index f74598ad5..ff2e539d1 100644
--- a/src/core/weechat.c
+++ b/src/core/weechat.c
@@ -60,6 +60,7 @@
 #include "wee-eval.h"
 #include "wee-hdata.h"
 #include "wee-hook.h"
+#include "wee-list.h"
 #include "wee-log.h"
 #include "wee-network.h"
 #include "wee-proxy.h"
@@ -102,7 +103,8 @@ int weechat_no_gnutls = 0;             /* remove init/deinit of gnutls      */
                                        /* (useful with valgrind/electric-f.)*/
 int weechat_no_gcrypt = 0;             /* remove init/deinit of gcrypt      */
                                        /* (useful with valgrind)            */
-char *weechat_startup_commands = NULL; /* startup commands (-r flag)        */
+struct t_weelist *weechat_startup_commands = NULL; /* startup commands      */
+                                                   /* (option -r)           */
 
 
 /*
@@ -152,9 +154,13 @@ weechat_display_usage ()
           "  -h, --help               display this help\n"
           "  -l, --license            display WeeChat license\n"
           "  -p, --no-plugin          don't load any plugin at startup\n"
-          "  -r, --run-command <cmd>  run command(s) after startup\n"
-          "                           (many commands can be separated by "
-          "semicolons)\n"
+          "  -P, --plugins <plugins>  load only these plugins at startup\n"
+          "                           (see /help weechat.plugin.autoload)\n"
+          "  -r, --run-command <cmd>  run command(s) after startup;\n"
+          "                           many commands can be separated by "
+          "semicolons,\n"
+          "                           this option can be given multiple "
+          "times\n"
           "  -s, --no-script          don't load any script at startup\n"
           "      --upgrade            upgrade WeeChat using session files "
           "(see /help upgrade in WeeChat)\n"
@@ -276,9 +282,10 @@ weechat_parse_args (int argc, char *argv[])
         {
             if (i + 1 < argc)
             {
-                if (weechat_startup_commands)
-                    free (weechat_startup_commands);
-                weechat_startup_commands = strdup (argv[++i]);
+                if (!weechat_startup_commands)
+                    weechat_startup_commands = weelist_new ();
+                weelist_add (weechat_startup_commands, argv[++i],
+                             WEECHAT_LIST_POS_END, NULL);
             }
             else
             {
@@ -616,6 +623,8 @@ weechat_shutdown (int return_code, int crash)
         free (weechat_home);
     if (weechat_local_charset)
         free (weechat_local_charset);
+    if (weechat_startup_commands)
+        weelist_free (weechat_startup_commands);
 
     if (crash)
         abort ();
diff --git a/src/core/weechat.h b/src/core/weechat.h
index 9420ff415..cbb565a03 100644
--- a/src/core/weechat.h
+++ b/src/core/weechat.h
@@ -96,6 +96,8 @@
 /* name of environment variable with an extra lib dir */
 #define WEECHAT_EXTRA_LIBDIR "WEECHAT_EXTRA_LIBDIR"
 
+struct t_weelist;
+
 /* global variables and functions */
 extern int weechat_headless;
 extern int weechat_debug_core;
@@ -112,7 +114,7 @@ extern char *weechat_local_charset;
 extern int weechat_plugin_no_dlclose;
 extern int weechat_no_gnutls;
 extern int weechat_no_gcrypt;
-extern char *weechat_startup_commands;
+extern struct t_weelist *weechat_startup_commands;
 
 extern void weechat_term_check ();
 extern void weechat_shutdown (int return_code, int crash);