mirror of
https://github.com/weechat/weechat.git
synced 2026-07-02 07:46:38 +02:00
core: add command line option "-r" (or "--run-command") to run command(s) after startup of WeeChat
This commit is contained in:
committed by
Sebastien Helleu
parent
bb4264a56c
commit
4eb8013fd3
+21
-10
@@ -6214,23 +6214,18 @@ command_init ()
|
||||
}
|
||||
|
||||
/*
|
||||
* command_startup: execute command at startup
|
||||
* command_exec_list: execute command list
|
||||
*/
|
||||
|
||||
void
|
||||
command_startup (int plugins_loaded)
|
||||
command_exec_list (const char *command_list)
|
||||
{
|
||||
char *command, **commands, **ptr_cmd;
|
||||
char **commands, **ptr_cmd;
|
||||
struct t_gui_buffer *weechat_buffer;
|
||||
|
||||
if (plugins_loaded)
|
||||
command = CONFIG_STRING(config_startup_command_after_plugins);
|
||||
else
|
||||
command = CONFIG_STRING(config_startup_command_before_plugins);
|
||||
|
||||
if (command && command[0])
|
||||
if (command_list && command_list[0])
|
||||
{
|
||||
commands = string_split_command (command, ';');
|
||||
commands = string_split_command (command_list, ';');
|
||||
if (commands)
|
||||
{
|
||||
weechat_buffer = gui_buffer_search_main ();
|
||||
@@ -6242,3 +6237,19 @@ command_startup (int plugins_loaded)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* command_startup: execute command at startup
|
||||
*/
|
||||
|
||||
void
|
||||
command_startup (int plugins_loaded)
|
||||
{
|
||||
if (plugins_loaded)
|
||||
{
|
||||
command_exec_list(CONFIG_STRING(config_startup_command_after_plugins));
|
||||
command_exec_list(weechat_startup_commands);
|
||||
}
|
||||
else
|
||||
command_exec_list(CONFIG_STRING(config_startup_command_before_plugins));
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ struct t_gui_buffer;
|
||||
extern int command_reload (void *data, struct t_gui_buffer *buffer,
|
||||
int argc, char **argv, char **argv_eol);
|
||||
extern void command_init ();
|
||||
extern void command_startup (int plugins_looaded);
|
||||
extern void command_startup (int plugins_loaded);
|
||||
extern void command_version_display (struct t_gui_buffer *buffer,
|
||||
int send_to_buffer_as_input,
|
||||
int translated_string);
|
||||
|
||||
+34
-17
@@ -91,6 +91,7 @@ int weechat_server_cmd_line = 0; /* at least 1 server on cmd line */
|
||||
int weechat_auto_load_plugins = 1; /* auto load plugins */
|
||||
int weechat_plugin_no_dlclose = 0; /* remove calls to dlclose for libs */
|
||||
/* (useful when using valgrind) */
|
||||
char *weechat_startup_commands = NULL; /* startup commands (-r flag) */
|
||||
|
||||
|
||||
/*
|
||||
@@ -136,22 +137,24 @@ weechat_display_usage (char *exec_name)
|
||||
exec_name, exec_name);
|
||||
string_iconv_fprintf (stdout, "\n");
|
||||
string_iconv_fprintf (stdout,
|
||||
_(" -a, --no-connect disable auto-connect to servers at startup\n"
|
||||
" -c, --colors display default colors in terminal\n"
|
||||
" -d, --dir <path> set WeeChat home directory (default: ~/.weechat)\n"
|
||||
" -h, --help this help\n"
|
||||
" -k, --keys display WeeChat default keys\n"
|
||||
" -l, --license display WeeChat license\n"
|
||||
" -p, --no-plugin don't load any plugin at startup\n"
|
||||
" -s, --no-script don't load any script at startup\n"
|
||||
" -v, --version display WeeChat version\n"
|
||||
" plugin:option option for plugin\n"
|
||||
" for example, irc plugin can connect\n"
|
||||
" to server with url like:\n"
|
||||
" irc[6][s]://[nickname[:password]@]"
|
||||
_(" -a, --no-connect disable auto-connect to servers at startup\n"
|
||||
" -c, --colors display default colors in terminal\n"
|
||||
" -d, --dir <path> set WeeChat home directory (default: ~/.weechat)\n"
|
||||
" -h, --help this help\n"
|
||||
" -k, --keys display WeeChat default keys\n"
|
||||
" -l, --license display WeeChat license\n"
|
||||
" -p, --no-plugin don't load any plugin at startup\n"
|
||||
" -r, --run-command run command(s) after startup\n"
|
||||
" (many commands can be separated by semicolons)\n"
|
||||
" -s, --no-script don't load any script at startup\n"
|
||||
" -v, --version display WeeChat version\n"
|
||||
" plugin:option option for plugin\n"
|
||||
" for example, irc plugin can connect\n"
|
||||
" to server with url like:\n"
|
||||
" irc[6][s]://[nickname[:password]@]"
|
||||
"irc.example.org[:port][/#channel1][,#channel2[...]]\n"
|
||||
" (look at plugins documentation for more information\n"
|
||||
" about possible options)\n"));
|
||||
" (look at plugins documentation for more information\n"
|
||||
" about possible options)\n"));
|
||||
string_iconv_fprintf(stdout, "\n");
|
||||
}
|
||||
|
||||
@@ -223,7 +226,7 @@ weechat_parse_args (int argc, char *argv[])
|
||||
string_iconv_fprintf (stderr,
|
||||
_("Error: missing argument for \"%s\" "
|
||||
"option\n"),
|
||||
"--dir");
|
||||
argv[i]);
|
||||
weechat_shutdown (EXIT_FAILURE, 0);
|
||||
}
|
||||
}
|
||||
@@ -262,6 +265,20 @@ weechat_parse_args (int argc, char *argv[])
|
||||
{
|
||||
weechat_auto_load_plugins = 0;
|
||||
}
|
||||
else if ((strcmp (argv[i], "-r") == 0)
|
||||
|| (strcmp (argv[i], "--run-command") == 0))
|
||||
{
|
||||
if (i + 1 < argc)
|
||||
weechat_startup_commands = strdup (argv[++i]);
|
||||
else
|
||||
{
|
||||
string_iconv_fprintf (stderr,
|
||||
_("Error: missing argument for \"%s\" "
|
||||
"option\n"),
|
||||
argv[i]);
|
||||
weechat_shutdown (EXIT_FAILURE, 0);
|
||||
}
|
||||
}
|
||||
else if (strcmp (argv[i], "--upgrade") == 0)
|
||||
{
|
||||
weechat_upgrading = 1;
|
||||
@@ -466,7 +483,7 @@ main (int argc, char *argv[])
|
||||
command_startup (0); /* command executed before plugins */
|
||||
plugin_init (weechat_auto_load_plugins, /* init plugin interface(s) */
|
||||
argc, argv);
|
||||
command_startup (1); /* command executed after plugins */
|
||||
command_startup (1); /* commands executed after plugins */
|
||||
if (!weechat_upgrading)
|
||||
gui_layout_window_apply (gui_layout_windows, -1); /* apply win layout */
|
||||
if (weechat_upgrading)
|
||||
|
||||
@@ -108,6 +108,7 @@ extern int weechat_quit;
|
||||
extern char *weechat_home;
|
||||
extern char *weechat_local_charset;
|
||||
extern int weechat_plugin_no_dlclose;
|
||||
extern char *weechat_startup_commands;
|
||||
|
||||
extern void weechat_shutdown (int return_code, int crash);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user