diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2005-03-10 15:40:18 +0000 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2005-03-10 15:40:18 +0000 |
commit | 9fbd33faaf545859e3ff8af963e3113bd5001e73 (patch) | |
tree | 71782257d50e5cfc1e6720ed5d86015a41493a97 /src/common | |
parent | 5301c750217e493ff711eef8666ae2db74f46ecc (diff) | |
download | weechat-9fbd33faaf545859e3ff8af963e3113bd5001e73.zip |
Added --irc-commands and --weechat-commands command line options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/weechat.c | 63 | ||||
-rw-r--r-- | src/common/weechat.h | 10 |
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 */ |