summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/weechat.c63
-rw-r--r--src/common/weechat.h10
2 files changed, 69 insertions, 4 deletions
diff --git a/src/common/weechat.c b/src/common/weechat.c
index 924a68669..74d2c47cd 100644
--- a/src/common/weechat.c
+++ b/src/common/weechat.c
@@ -248,6 +248,57 @@ void wee_display_config_options ()
}
/*
+ * wee_display_commands: display WeeChat and/or IRC commands
+ */
+
+void wee_display_commands (int weechat_cmd, int irc_cmd)
+{
+ int i;
+
+ if (weechat_cmd)
+ {
+ printf (_("%s internal commands:\n"), PACKAGE_NAME);
+ printf ("\n");
+ for (i = 0; weechat_commands[i].command_name; i++)
+ {
+ printf ("* %s", weechat_commands[i].command_name);
+ if (weechat_commands[i].arguments &&
+ weechat_commands[i].arguments[0])
+ printf (" %s\n", _(weechat_commands[i].arguments));
+ else
+ printf ("\n");
+ if (weechat_commands[i].arguments_description &&
+ weechat_commands[i].arguments_description[0])
+ printf ("\n%s\n\n",
+ _(weechat_commands[i].arguments_description));
+ }
+ }
+
+ if (irc_cmd)
+ {
+ printf (_("IRC commands:\n"));
+ printf ("\n");
+ for (i = 0; irc_commands[i].command_name; i++)
+ {
+ if (irc_commands[i].cmd_function_args ||
+ irc_commands[i].cmd_function_1arg)
+ {
+ printf ("* %s", irc_commands[i].command_name);
+ if (irc_commands[i].arguments &&
+ irc_commands[i].arguments[0])
+ printf (" %s\n", _(irc_commands[i].arguments));
+ else
+ printf ("\n");
+ if (irc_commands[i].arguments_description &&
+ irc_commands[i].arguments_description[0])
+ printf ("\n%s\n\n",
+ _(irc_commands[i].arguments_description));
+ }
+ }
+ }
+}
+
+/*
* wee_parse_args: parse command line args
*/
@@ -274,6 +325,12 @@ wee_parse_args (int argc, char *argv[])
printf ("%s", WEE_USAGE2);
wee_shutdown (EXIT_SUCCESS);
}
+ if ((strcmp (argv[i], "-i") == 0)
+ || (strcmp (argv[i], "--irc-commands") == 0))
+ {
+ wee_display_commands (0, 1);
+ wee_shutdown (EXIT_SUCCESS);
+ }
else if ((strcmp (argv[i], "-l") == 0)
|| (strcmp (argv[i], "--license") == 0))
{
@@ -286,6 +343,12 @@ wee_parse_args (int argc, char *argv[])
printf (PACKAGE_VERSION "\n");
wee_shutdown (EXIT_SUCCESS);
}
+ if ((strcmp (argv[i], "-w") == 0)
+ || (strcmp (argv[i], "--weechat-commands") == 0))
+ {
+ wee_display_commands (1, 0);
+ wee_shutdown (EXIT_SUCCESS);
+ }
else if ((strncasecmp (argv[i], "irc://", 6) == 0))
{
if (server_init_with_url (argv[i], &server_tmp) < 0)
diff --git a/src/common/weechat.h b/src/common/weechat.h
index 6e60acedd..24520765e 100644
--- a/src/common/weechat.h
+++ b/src/common/weechat.h
@@ -81,10 +81,12 @@
" or: %s [irc://[nickname[:password]@]irc.example.org[:port][/channel] ...]\n\n"
#define WEE_USAGE2 \
- " -c, --config config file help (list of options)\n" \
- " -h, --help this help screen\n" \
- " -l, --license display WeeChat license\n" \
- " -v, --version display WeeChat version\n\n"
+ " -c, --config display config file options\n" \
+ " -h, --help this help screen\n" \
+ " -i, --irc-commands display IRC commands\n" \
+ " -l, --license display WeeChat license\n" \
+ " -v, --version display WeeChat version\n" \
+ " -w, --weechat-commands display WeeChat commands\n\n"
/* directory separator, depending on OS */