1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-09-22 19:45:54 -04:00

Added tags to command definitions

This commit is contained in:
James Booth 2015-07-27 01:06:10 +01:00
parent 8119025120
commit eb550eedb3
5 changed files with 358 additions and 86 deletions

View File

@ -104,11 +104,22 @@ static char * _receipts_autocomplete(ProfWin *window, const char * const input);
GHashTable *commands = NULL;
#define CMD_SYN(...) { { __VA_ARGS__, NULL },
#define CMD_TAG_BASIC "basic"
#define CMD_TAG_CHATTING "chatting"
#define CMD_TAG_GROUPCHAT "groupchat"
#define CMD_TAG_PRESENCES "presences"
#define CMD_TAG_CONTACTS "contacts"
#define CMD_TAG_SERVICE "service"
#define CMD_TAG_SETTINGS "settings"
#define CMD_TAG_UI "ui"
#define CMD_NOTAGS { { NULL },
#define CMD_TAGS(...) { { __VA_ARGS__, NULL },
#define CMD_SYN(...) { __VA_ARGS__, NULL },
#define CMD_DESC(desc) desc,
#define CMD_NOARGS { { NULL, NULL } },
#define CMD_NOARGS { { NULL, NULL } },
#define CMD_ARGS(...) { __VA_ARGS__, { NULL, NULL } },
#define CMD_NOEXAMPLES { NULL } }
#define CMD_NOEXAMPLES { NULL } }
#define CMD_EXAMPLES(...) { __VA_ARGS__, NULL } }
/*
@ -118,6 +129,7 @@ static struct cmd_t command_defs[] =
{
{ "/help",
cmd_help, parse_args, 0, 1, NULL,
CMD_NOTAGS
CMD_SYN(
"/help [<area>|<command>]")
CMD_DESC(
@ -133,6 +145,7 @@ static struct cmd_t command_defs[] =
{ "/about",
cmd_about, parse_args, 0, 0, NULL,
CMD_NOTAGS
CMD_SYN(
"/about")
CMD_DESC(
@ -143,6 +156,8 @@ static struct cmd_t command_defs[] =
{ "/connect",
cmd_connect, parse_args, 0, 5, NULL,
CMD_TAGS(
CMD_TAG_BASIC)
CMD_SYN(
"/connect [<account>]",
"/connect <account> [server <server>] [port <port>]")
@ -164,6 +179,8 @@ static struct cmd_t command_defs[] =
{ "/disconnect",
cmd_disconnect, parse_args, 0, 0, NULL,
CMD_TAGS(
CMD_TAG_BASIC)
CMD_SYN(
"/disconnect")
CMD_DESC(
@ -174,6 +191,10 @@ static struct cmd_t command_defs[] =
{ "/msg",
cmd_msg, parse_args_with_freetext, 1, 2, NULL,
CMD_TAGS(
CMD_TAG_BASIC,
CMD_TAG_CHATTING,
CMD_TAG_GROUPCHAT)
CMD_SYN(
"/msg <contact> [<message>]",
"/msg <nick> [<message>]")
@ -195,6 +216,9 @@ static struct cmd_t command_defs[] =
{ "/roster",
cmd_roster, parse_args_with_freetext, 0, 3, NULL,
CMD_TAGS(
CMD_TAG_CONTACTS,
CMD_TAG_UI)
CMD_SYN(
"/roster",
"/roster online",
@ -242,9 +266,12 @@ static struct cmd_t command_defs[] =
{ "/group",
cmd_group, parse_args_with_freetext, 0, 3, NULL,
CMD_TAGS(
CMD_TAG_CONTACTS)
CMD_SYN(
"/group",
"/group show <group>",
"/group add <group> <contat>"
"/group remove <group> <contact>")
CMD_DESC(
"View, add to, and remove from roster groups. "
@ -263,6 +290,7 @@ static struct cmd_t command_defs[] =
{ "/info",
cmd_info, parse_args, 0, 1, NULL,
CMD_NOTAGS
CMD_SYN(
"/info",
"/info <contact>|<nick>")
@ -280,6 +308,8 @@ static struct cmd_t command_defs[] =
{ "/caps",
cmd_caps, parse_args, 0, 1, NULL,
CMD_TAGS(
CMD_TAG_SERVICE)
CMD_SYN(
"/caps",
"/caps <fulljid>|<nick>")
@ -297,6 +327,8 @@ static struct cmd_t command_defs[] =
{ "/software",
cmd_software, parse_args, 0, 1, NULL,
CMD_TAGS(
CMD_TAG_SERVICE)
CMD_SYN(
"/software",
"/software <fulljid>|<nick>")
@ -315,6 +347,7 @@ static struct cmd_t command_defs[] =
{ "/status",
cmd_status, parse_args, 0, 1, NULL,
CMD_NOTAGS
CMD_SYN(
"/status",
"/status <contact>|<nick>")
@ -331,6 +364,8 @@ static struct cmd_t command_defs[] =
{ "/resource",
cmd_resource, parse_args, 1, 2, &cons_resource_setting,
CMD_TAGS(
CMD_TAG_UI)
CMD_SYN(
"/resource set <resource>",
"/resource off",
@ -348,6 +383,9 @@ static struct cmd_t command_defs[] =
{ "/join",
cmd_join, parse_args, 0, 5, NULL,
CMD_TAGS(
CMD_TAG_BASIC,
CMD_TAG_GROUPCHAT)
CMD_SYN(
"/join",
"/join <room> [nick <nick>] [password <password>]")
@ -371,6 +409,9 @@ static struct cmd_t command_defs[] =
{ "/leave",
cmd_leave, parse_args, 0, 0, NULL,
CMD_TAGS(
CMD_TAG_BASIC,
CMD_TAG_GROUPCHAT)
CMD_SYN(
"/leave")
CMD_DESC(
@ -381,6 +422,8 @@ static struct cmd_t command_defs[] =
{ "/invite",
cmd_invite, parse_args_with_freetext, 1, 2, NULL,
CMD_TAGS(
CMD_TAG_GROUPCHAT)
CMD_SYN(
"/invite <contact> [<message>]")
CMD_DESC(
@ -393,6 +436,8 @@ static struct cmd_t command_defs[] =
{ "/invites",
cmd_invites, parse_args_with_freetext, 0, 0, NULL,
CMD_TAGS(
CMD_TAG_GROUPCHAT)
CMD_SYN(
"/invites")
CMD_DESC(
@ -403,6 +448,8 @@ static struct cmd_t command_defs[] =
{ "/decline",
cmd_decline, parse_args_with_freetext, 1, 1, NULL,
CMD_TAGS(
CMD_TAG_GROUPCHAT)
CMD_SYN(
"/decline <room>")
CMD_DESC(
@ -414,6 +461,8 @@ static struct cmd_t command_defs[] =
{ "/room",
cmd_room, parse_args, 1, 1, NULL,
CMD_TAGS(
CMD_TAG_GROUPCHAT)
CMD_SYN(
"/room accept|destroy|config")
CMD_DESC(
@ -427,6 +476,8 @@ static struct cmd_t command_defs[] =
{ "/kick",
cmd_kick, parse_args_with_freetext, 1, 2, NULL,
CMD_TAGS(
CMD_TAG_GROUPCHAT)
CMD_SYN(
"/kick <nick> [<reason>]")
CMD_DESC(
@ -439,6 +490,8 @@ static struct cmd_t command_defs[] =
{ "/ban",
cmd_ban, parse_args_with_freetext, 1, 2, NULL,
CMD_TAGS(
CMD_TAG_GROUPCHAT)
CMD_SYN(
"/ban <jid> [<reason>]")
CMD_DESC(
@ -451,6 +504,8 @@ static struct cmd_t command_defs[] =
{ "/subject",
cmd_subject, parse_args_with_freetext, 0, 2, NULL,
CMD_TAGS(
CMD_TAG_GROUPCHAT)
CMD_SYN(
"/subject set <subject>",
"/subject clear")
@ -464,6 +519,8 @@ static struct cmd_t command_defs[] =
{ "/affiliation",
cmd_affiliation, parse_args_with_freetext, 1, 4, NULL,
CMD_TAGS(
CMD_TAG_GROUPCHAT)
CMD_SYN(
"/affiliation set <affiliation> <jid> [<reason>]",
"/list [<affiliation>]")
@ -478,6 +535,8 @@ static struct cmd_t command_defs[] =
{ "/role",
cmd_role, parse_args_with_freetext, 1, 4, NULL,
CMD_TAGS(
CMD_TAG_GROUPCHAT)
CMD_SYN(
"/role set <role> <nick> [<reason>]",
"/list [<role>]")
@ -492,6 +551,8 @@ static struct cmd_t command_defs[] =
{ "/occupants",
cmd_occupants, parse_args, 1, 3, cons_occupants_setting,
CMD_TAGS(
CMD_TAG_UI)
CMD_SYN(
"/occupants show|hide [jid]",
"/occupants default show|hide [jid]",
@ -511,6 +572,8 @@ static struct cmd_t command_defs[] =
{ "/form",
cmd_form, parse_args, 1, 2, NULL,
CMD_TAGS(
CMD_TAG_GROUPCHAT)
CMD_SYN(
"/form show",
"/form submit",
@ -528,6 +591,8 @@ static struct cmd_t command_defs[] =
{ "/rooms",
cmd_rooms, parse_args, 0, 1, NULL,
CMD_TAGS(
CMD_TAG_GROUPCHAT)
CMD_SYN(
"/rooms [<service>]")
CMD_DESC(
@ -541,6 +606,8 @@ static struct cmd_t command_defs[] =
{ "/bookmark",
cmd_bookmark, parse_args, 0, 8, NULL,
CMD_TAGS(
CMD_TAG_GROUPCHAT)
CMD_SYN(
"/bookmark",
"/bookmark list",
@ -565,6 +632,8 @@ static struct cmd_t command_defs[] =
{ "/disco",
cmd_disco, parse_args, 1, 2, NULL,
CMD_TAGS(
CMD_TAG_SERVICE)
CMD_SYN(
"/disco info [<jid>]",
"/disco items [<jid>]")
@ -583,6 +652,9 @@ static struct cmd_t command_defs[] =
{ "/nick",
cmd_nick, parse_args_with_freetext, 1, 1, NULL,
CMD_TAGS(
CMD_TAG_BASIC,
CMD_TAG_GROUPCHAT)
CMD_SYN(
"/nick <nickname>")
CMD_DESC(
@ -594,6 +666,9 @@ static struct cmd_t command_defs[] =
{ "/win",
cmd_win, parse_args, 1, 1, NULL,
CMD_TAGS(
CMD_TAG_BASIC,
CMD_TAG_UI)
CMD_SYN(
"/win <num>")
CMD_DESC(
@ -605,6 +680,9 @@ static struct cmd_t command_defs[] =
{ "/wins",
cmd_wins, parse_args, 0, 3, NULL,
CMD_TAGS(
CMD_TAG_BASIC,
CMD_TAG_UI)
CMD_SYN(
"/wins tidy",
"/wins prune",
@ -621,6 +699,9 @@ static struct cmd_t command_defs[] =
{ "/sub",
cmd_sub, parse_args, 1, 2, NULL,
CMD_TAGS(
CMD_TAG_BASIC,
CMD_TAG_CONTACTS)
CMD_SYN(
"/sub request [<jid>]",
"/sub allow [<jid>]",
@ -647,6 +728,8 @@ static struct cmd_t command_defs[] =
{ "/tiny",
cmd_tiny, parse_args, 1, 1, NULL,
CMD_TAGS(
CMD_TAG_CHATTING)
CMD_SYN(
"/tiny <url>")
CMD_DESC(
@ -659,6 +742,9 @@ static struct cmd_t command_defs[] =
{ "/who",
cmd_who, parse_args, 0, 2, NULL,
CMD_TAGS(
CMD_TAG_BASIC,
CMD_TAG_CONTACTS)
CMD_SYN(
"/who",
"/who online|offline|away|dnd|xa|chat|available|unavailable|any [<group>]",
@ -686,6 +772,9 @@ static struct cmd_t command_defs[] =
{ "/close",
cmd_close, parse_args, 0, 1, NULL,
CMD_TAGS(
CMD_TAG_BASIC,
CMD_TAG_CHATTING)
CMD_SYN(
"/close [<num>]",
"/close all|read")
@ -701,6 +790,7 @@ static struct cmd_t command_defs[] =
{ "/clear",
cmd_clear, parse_args, 0, 0, NULL,
CMD_NOTAGS
CMD_SYN(
"/clear")
CMD_DESC(
@ -711,6 +801,8 @@ static struct cmd_t command_defs[] =
{ "/quit",
cmd_quit, parse_args, 0, 0, NULL,
CMD_TAGS(
CMD_TAG_BASIC)
CMD_SYN(
"/quit")
CMD_DESC(
@ -721,6 +813,8 @@ static struct cmd_t command_defs[] =
{ "/privileges",
cmd_privileges, parse_args, 1, 1, &cons_privileges_setting,
CMD_TAGS(
CMD_TAG_UI)
CMD_SYN(
"/privileges on|off")
CMD_DESC(
@ -732,6 +826,8 @@ static struct cmd_t command_defs[] =
{ "/beep",
cmd_beep, parse_args, 1, 1, &cons_beep_setting,
CMD_TAGS(
CMD_TAG_UI)
CMD_SYN(
"/beep on|off")
CMD_DESC(
@ -745,6 +841,9 @@ static struct cmd_t command_defs[] =
{ "/encwarn",
cmd_encwarn, parse_args, 1, 1, &cons_encwarn_setting,
CMD_TAGS(
CMD_TAG_CHATTING,
CMD_TAG_UI)
CMD_SYN(
"/encwarn on|off")
CMD_DESC(
@ -756,6 +855,8 @@ static struct cmd_t command_defs[] =
{ "/presence",
cmd_presence, parse_args, 1, 1, &cons_presence_setting,
CMD_TAGS(
CMD_TAG_UI)
CMD_SYN(
"/presence on|off")
CMD_DESC(
@ -767,6 +868,8 @@ static struct cmd_t command_defs[] =
{ "/wrap",
cmd_wrap, parse_args, 1, 1, &cons_wrap_setting,
CMD_TAGS(
CMD_TAG_UI)
CMD_SYN(
"/wrap on|off")
CMD_DESC(
@ -778,6 +881,8 @@ static struct cmd_t command_defs[] =
{ "/winstidy",
cmd_winstidy, parse_args, 1, 1, &cons_winstidy_setting,
CMD_TAGS(
CMD_TAG_UI)
CMD_SYN(
"/winstidy on|off")
CMD_DESC(
@ -789,6 +894,8 @@ static struct cmd_t command_defs[] =
{ "/time",
cmd_time, parse_args, 1, 3, &cons_time_setting,
CMD_TAGS(
CMD_TAG_UI)
CMD_SYN(
"/time main set <format>",
"/time main off",
@ -813,6 +920,8 @@ static struct cmd_t command_defs[] =
{ "/inpblock",
cmd_inpblock, parse_args, 2, 2, &cons_inpblock_setting,
CMD_TAGS(
CMD_TAG_UI)
CMD_SYN(
"/inpblock timeout <millis>",
"/inpblock dynamic on|off")
@ -826,6 +935,8 @@ static struct cmd_t command_defs[] =
{ "/notify",
cmd_notify, parse_args, 2, 3, &cons_notify_setting,
CMD_TAGS(
CMD_TAG_UI)
CMD_SYN(
"/notify message on|off",
"/notify message current on|off",
@ -865,6 +976,8 @@ static struct cmd_t command_defs[] =
{ "/flash",
cmd_flash, parse_args, 1, 1, &cons_flash_setting,
CMD_TAGS(
CMD_TAG_UI)
CMD_SYN(
"/flash on|off")
CMD_DESC(
@ -877,6 +990,8 @@ static struct cmd_t command_defs[] =
{ "/intype",
cmd_intype, parse_args, 1, 1, &cons_intype_setting,
CMD_TAGS(
CMD_TAG_UI)
CMD_SYN(
"/intype on|off")
CMD_DESC(
@ -888,6 +1003,8 @@ static struct cmd_t command_defs[] =
{ "/splash",
cmd_splash, parse_args, 1, 1, &cons_splash_setting,
CMD_TAGS(
CMD_TAG_UI)
CMD_SYN(
"/splash on|off")
CMD_DESC(
@ -899,6 +1016,8 @@ static struct cmd_t command_defs[] =
{ "/autoconnect",
cmd_autoconnect, parse_args, 1, 2, &cons_autoconnect_setting,
CMD_TAGS(
CMD_TAG_SETTINGS)
CMD_SYN(
"/autoconnect set <account>",
"/autoconnect off")
@ -915,6 +1034,9 @@ static struct cmd_t command_defs[] =
{ "/vercheck",
cmd_vercheck, parse_args, 0, 1, NULL,
CMD_TAGS(
CMD_TAG_SETTINGS,
CMD_TAG_UI)
CMD_SYN(
"/vercheck on|off")
CMD_DESC(
@ -926,6 +1048,8 @@ static struct cmd_t command_defs[] =
{ "/titlebar",
cmd_titlebar, parse_args, 2, 2, &cons_titlebar_setting,
CMD_TAGS(
CMD_TAG_UI)
CMD_SYN(
"/titlebar show on|off",
"/titlebar goodbye on|off")
@ -939,6 +1063,8 @@ static struct cmd_t command_defs[] =
{ "/alias",
cmd_alias, parse_args_with_freetext, 1, 3, NULL,
CMD_TAGS(
CMD_TAG_SETTINGS)
CMD_SYN(
"/alias list",
"/alias add <name> <value>",
@ -959,6 +1085,9 @@ static struct cmd_t command_defs[] =
{ "/chlog",
cmd_chlog, parse_args, 1, 1, &cons_chlog_setting,
CMD_TAGS(
CMD_TAG_CHATTING,
CMD_TAG_SETTINGS)
CMD_SYN(
"/chlog on|off")
CMD_DESC(
@ -973,6 +1102,9 @@ static struct cmd_t command_defs[] =
{ "/grlog",
cmd_grlog, parse_args, 1, 1, &cons_grlog_setting,
CMD_TAGS(
CMD_TAG_GROUPCHAT,
CMD_TAG_SETTINGS)
CMD_SYN(
"/grlog on|off")
CMD_DESC(
@ -985,6 +1117,8 @@ static struct cmd_t command_defs[] =
{ "/states",
cmd_states, parse_args, 1, 1, &cons_states_setting,
CMD_TAGS(
CMD_TAG_SETTINGS)
CMD_SYN(
"/states on|off")
CMD_DESC(
@ -996,6 +1130,8 @@ static struct cmd_t command_defs[] =
{ "/pgp",
cmd_pgp, parse_args, 1, 3, NULL,
CMD_TAGS(
CMD_TAG_CHATTING)
CMD_SYN(
"/pgp libver",
"/pgp keys",
@ -1025,6 +1161,8 @@ static struct cmd_t command_defs[] =
{ "/otr",
cmd_otr, parse_args, 1, 3, NULL,
CMD_TAGS(
CMD_TAG_CHATTING)
CMD_SYN(
"/otr libver",
"/otr gen",
@ -1068,6 +1206,8 @@ static struct cmd_t command_defs[] =
{ "/outtype",
cmd_outtype, parse_args, 1, 1, &cons_outtype_setting,
CMD_TAGS(
CMD_TAG_SETTINGS)
CMD_SYN(
"/outtype on|off")
CMD_DESC(
@ -1079,6 +1219,8 @@ static struct cmd_t command_defs[] =
{ "/gone",
cmd_gone, parse_args, 1, 1, &cons_gone_setting,
CMD_TAGS(
CMD_TAG_SETTINGS)
CMD_SYN(
"/gone <minutes>")
CMD_DESC(
@ -1091,6 +1233,10 @@ static struct cmd_t command_defs[] =
{ "/history",
cmd_history, parse_args, 1, 1, &cons_history_setting,
CMD_TAGS(
CMD_TAG_CHATTING,
CMD_TAG_SETTINGS,
CMD_TAG_UI)
CMD_SYN(
"/history on|off")
CMD_DESC(
@ -1103,6 +1249,8 @@ static struct cmd_t command_defs[] =
{ "/log",
cmd_log, parse_args, 1, 2, &cons_log_setting,
CMD_TAGS(
CMD_TAG_SETTINGS)
CMD_SYN(
"/log where",
"/log rotate on|off",
@ -1120,6 +1268,9 @@ static struct cmd_t command_defs[] =
{ "/carbons",
cmd_carbons, parse_args, 1, 1, &cons_carbons_setting,
CMD_TAGS(
CMD_TAG_CHATTING,
CMD_TAG_SETTINGS)
CMD_SYN(
"/carbons on|off")
CMD_DESC(
@ -1132,6 +1283,9 @@ static struct cmd_t command_defs[] =
{ "/receipts",
cmd_receipts, parse_args, 2, 2, &cons_receipts_setting,
CMD_TAGS(
CMD_TAG_CHATTING,
CMD_TAG_SETTINGS)
CMD_SYN(
"/receipts request on|off",
"/receipts send on|off")
@ -1145,6 +1299,8 @@ static struct cmd_t command_defs[] =
{ "/reconnect",
cmd_reconnect, parse_args, 1, 1, &cons_reconnect_setting,
CMD_TAGS(
CMD_TAG_SETTINGS)
CMD_SYN(
"/reconnect <seconds>")
CMD_DESC(
@ -1156,6 +1312,8 @@ static struct cmd_t command_defs[] =
{ "/autoping",
cmd_autoping, parse_args, 1, 1, &cons_autoping_setting,
CMD_TAGS(
CMD_TAG_SETTINGS)
CMD_SYN(
"/autoping <seconds>")
CMD_DESC(
@ -1167,6 +1325,7 @@ static struct cmd_t command_defs[] =
{ "/ping",
cmd_ping, parse_args, 0, 1, NULL,
CMD_NOTAGS
CMD_SYN(
"/ping [<jid>]")
CMD_DESC(
@ -1179,6 +1338,9 @@ static struct cmd_t command_defs[] =
{ "/autoaway",
cmd_autoaway, parse_args_with_freetext, 2, 2, &cons_autoaway_setting,
CMD_TAGS(
CMD_TAG_PRESENCES,
CMD_TAG_SETTINGS)
CMD_SYN(
"/autoaway mode idle|away|off",
"/autoaway time <minutes>",
@ -1203,6 +1365,8 @@ static struct cmd_t command_defs[] =
{ "/priority",
cmd_priority, parse_args, 1, 1, &cons_priority_setting,
CMD_TAGS(
CMD_TAG_PRESENCES)
CMD_SYN(
"/priority <priority>")
CMD_DESC(
@ -1215,6 +1379,8 @@ static struct cmd_t command_defs[] =
{ "/account",
cmd_account, parse_args, 0, 4, NULL,
CMD_TAGS(
CMD_TAG_SETTINGS)
CMD_SYN(
"/account",
"/account list",
@ -1288,6 +1454,9 @@ static struct cmd_t command_defs[] =
{ "/prefs",
cmd_prefs, parse_args, 0, 1, NULL,
CMD_TAGS(
CMD_TAG_SETTINGS,
CMD_TAG_UI)
CMD_SYN(
"/prefs [ui|desktop|chat|log|conn|presence]")
CMD_DESC(
@ -1305,6 +1474,8 @@ static struct cmd_t command_defs[] =
{ "/theme",
cmd_theme, parse_args, 1, 2, &cons_theme_setting,
CMD_TAGS(
CMD_TAG_UI)
CMD_SYN(
"/theme list",
"/theme load <theme>",
@ -1322,6 +1493,8 @@ static struct cmd_t command_defs[] =
{ "/statuses",
cmd_statuses, parse_args, 2, 2, &cons_statuses_setting,
CMD_TAGS(
CMD_TAG_UI)
CMD_SYN(
"/statuses console|chat|muc all|online|none")
CMD_DESC(
@ -1342,6 +1515,8 @@ static struct cmd_t command_defs[] =
{ "/xmlconsole",
cmd_xmlconsole, parse_args, 0, 0, NULL,
CMD_TAGS(
CMD_TAG_UI)
CMD_SYN(
"/xmlconsole")
CMD_DESC(
@ -1352,6 +1527,9 @@ static struct cmd_t command_defs[] =
{ "/away",
cmd_away, parse_args_with_freetext, 0, 1, NULL,
CMD_TAGS(
CMD_TAG_BASIC,
CMD_TAG_PRESENCES)
CMD_SYN(
"/away [<message>]")
CMD_DESC(
@ -1365,6 +1543,9 @@ static struct cmd_t command_defs[] =
{ "/chat",
cmd_chat, parse_args_with_freetext, 0, 1, NULL,
CMD_TAGS(
CMD_TAG_BASIC,
CMD_TAG_PRESENCES)
CMD_SYN(
"/chat [<message>]")
CMD_DESC(
@ -1378,6 +1559,9 @@ static struct cmd_t command_defs[] =
{ "/dnd",
cmd_dnd, parse_args_with_freetext, 0, 1, NULL,
CMD_TAGS(
CMD_TAG_BASIC,
CMD_TAG_PRESENCES)
CMD_SYN(
"/dnd [<message>]")
CMD_DESC(
@ -1391,6 +1575,9 @@ static struct cmd_t command_defs[] =
{ "/online",
cmd_online, parse_args_with_freetext, 0, 1, NULL,
CMD_TAGS(
CMD_TAG_BASIC,
CMD_TAG_PRESENCES)
CMD_SYN(
"/online [<message>]")
CMD_DESC(
@ -1404,6 +1591,9 @@ static struct cmd_t command_defs[] =
{ "/xa",
cmd_xa, parse_args_with_freetext, 0, 1, NULL,
CMD_TAGS(
CMD_TAG_BASIC,
CMD_TAG_PRESENCES)
CMD_SYN(
"/xa [<message>]")
CMD_DESC(
@ -1494,6 +1684,7 @@ cmd_init(void)
autocomplete_add(help_ac, "contacts");
autocomplete_add(help_ac, "service");
autocomplete_add(help_ac, "settings");
autocomplete_add(help_ac, "ui");
autocomplete_add(help_ac, "navigation");
// load command defs into hash table
@ -2120,6 +2311,32 @@ cmd_reset_autocomplete(ProfWin *window)
bookmark_autocomplete_reset();
}
gboolean
cmd_is_tag(const char * const str)
{
return ((g_strcmp0(str, CMD_TAG_BASIC) == 0) ||
(g_strcmp0(str, CMD_TAG_CHATTING) == 0) ||
(g_strcmp0(str, CMD_TAG_CONTACTS) == 0) ||
(g_strcmp0(str, CMD_TAG_GROUPCHAT) == 0) ||
(g_strcmp0(str, CMD_TAG_PRESENCES) == 0) ||
(g_strcmp0(str, CMD_TAG_SERVICE) == 0) ||
(g_strcmp0(str, CMD_TAG_UI) == 0) ||
(g_strcmp0(str, CMD_TAG_SETTINGS) == 0));
}
gboolean
cmd_has_tag(Command *pcmd, const char * const tag)
{
int i = 0;
for (i = 0; pcmd->help.tags[i] != NULL; i++) {
if (g_strcmp0(tag, pcmd->help.tags[i]) == 0) {
return TRUE;
}
}
return FALSE;
}
/*
* Take a line of input and process it, return TRUE if profanity is to
* continue, FALSE otherwise

View File

@ -54,6 +54,9 @@ void cmd_autocomplete_remove_form_fields(DataForm *form);
void cmd_alias_add(char *value);
void cmd_alias_remove(char *value);
gboolean cmd_is_tag(const char * const str);
gboolean cmd_has_tag(Command *pcmd, const char * const tag);
gboolean cmd_process_input(ProfWin *window, char *inp);
void cmd_execute_connect(ProfWin *window, const char * const account);

View File

@ -75,7 +75,7 @@ static void _update_presence(const resource_presence_t presence,
const char * const show, gchar **args);
static gboolean _cmd_set_boolean_preference(gchar *arg, const char * const command,
const char * const display, preference_t pref);
static void _cmd_show_filtered_help(char *heading, gchar *cmd_filter[], int filter_size);
//static void _cmd_show_filtered_help(char *heading, gchar *cmd_filter[], int filter_size);
static void _who_room(ProfWin *window, const char * const command, gchar **args);
static void _who_roster(ProfWin *window, const char * const command, gchar **args);
@ -828,46 +828,96 @@ cmd_help(ProfWin *window, const char * const command, gchar **args)
cons_show("Use /help [command] without the leading slash, for help on a specific command");
cons_show("");
} else if (strcmp(args[0], "basic") == 0) {
gchar *filter[] = { "/about", "/clear", "/close", "/connect",
"/disconnect", "/help", "/msg", "/join", "/quit", "/vercheck",
"/wins", "/ping" };
_cmd_show_filtered_help("Basic commands", filter, ARRAY_SIZE(filter));
// } else if (strcmp(args[0], "basic") == 0) {
// gchar *filter[] = { "/about", "/clear", "/close", "/connect",
// "/disconnect", "/help", "/msg", "/join", "/quit", "/vercheck",
// "/wins", "/ping" };
// _cmd_show_filtered_help("Basic commands", filter, ARRAY_SIZE(filter));
//
// } else if (strcmp(args[0], "chatting") == 0) {
// gchar *filter[] = { "/chlog", "/otr", "/gone", "/history",
// "/info", "/intype", "/msg", "/notify", "/outtype", "/status",
// "/close", "/clear", "/tiny" };
// _cmd_show_filtered_help("Chat commands", filter, ARRAY_SIZE(filter));
//
// } else if (strcmp(args[0], "groupchat") == 0) {
// gchar *filter[] = { "/close", "/clear", "/decline", "/grlog",
// "/invite", "/invites", "/join", "/leave", "/notify", "/msg", "/room",
// "/rooms", "/tiny", "/who", "/nick", "/privileges", "/info", "/occupants" };
// _cmd_show_filtered_help("Groupchat commands", filter, ARRAY_SIZE(filter));
//
// } else if (strcmp(args[0], "presences") == 0) {
// gchar *filter[] = { "/autoaway", "/away", "/chat", "/dnd",
// "/online", "/priority", "/account", "/status", "/statuses", "/who",
// "/xa" };
// _cmd_show_filtered_help("Presence commands", filter, ARRAY_SIZE(filter));
//
// } else if (strcmp(args[0], "contacts") == 0) {
// gchar *filter[] = { "/group", "/roster", "/sub", "/who" };
// _cmd_show_filtered_help("Roster commands", filter, ARRAY_SIZE(filter));
//
// } else if (strcmp(args[0], "service") == 0) {
// gchar *filter[] = { "/caps", "/disco", "/info", "/software", "/rooms" };
// _cmd_show_filtered_help("Service discovery commands", filter, ARRAY_SIZE(filter));
//
// } else if (strcmp(args[0], "settings") == 0) {
// gchar *filter[] = { "/account", "/autoaway", "/autoping", "/autoconnect", "/beep",
// "/carbons", "/chlog", "/flash", "/gone", "/grlog", "/history", "/intype",
// "/log", "/notify", "/outtype", "/prefs", "/priority", "/reconnect", "/roster",
// "/splash", "/states", "/statuses", "/theme", "/titlebar", "/vercheck",
// "/privileges", "/occupants", "/presence", "/wrap", "/winstidy" };
// _cmd_show_filtered_help("Settings commands", filter, ARRAY_SIZE(filter));
//
} else if (cmd_is_tag(args[0])) {
cons_show("");
ProfWin *console = wins_get_console();
win_vprint(console, '-', NULL, 0, THEME_WHITE_BOLD, "", "%s commands", args[0]);
} else if (strcmp(args[0], "chatting") == 0) {
gchar *filter[] = { "/chlog", "/otr", "/gone", "/history",
"/info", "/intype", "/msg", "/notify", "/outtype", "/status",
"/close", "/clear", "/tiny" };
_cmd_show_filtered_help("Chat commands", filter, ARRAY_SIZE(filter));
GList *ordered_commands = NULL;
GHashTableIter iter;
gpointer key;
gpointer value;
} else if (strcmp(args[0], "groupchat") == 0) {
gchar *filter[] = { "/close", "/clear", "/decline", "/grlog",
"/invite", "/invites", "/join", "/leave", "/notify", "/msg", "/room",
"/rooms", "/tiny", "/who", "/nick", "/privileges", "/info", "/occupants" };
_cmd_show_filtered_help("Groupchat commands", filter, ARRAY_SIZE(filter));
g_hash_table_iter_init(&iter, commands);
while (g_hash_table_iter_next(&iter, &key, &value)) {
Command *pcmd = (Command *)value;
if (cmd_has_tag(pcmd, args[0])) {
ordered_commands = g_list_insert_sorted(ordered_commands, pcmd->cmd, (GCompareFunc)g_strcmp0);
}
}
} else if (strcmp(args[0], "presences") == 0) {
gchar *filter[] = { "/autoaway", "/away", "/chat", "/dnd",
"/online", "/priority", "/account", "/status", "/statuses", "/who",
"/xa" };
_cmd_show_filtered_help("Presence commands", filter, ARRAY_SIZE(filter));
int maxlen = 0;
GList *curr = ordered_commands;
while (curr) {
gchar *cmd = curr->data;
int len = strlen(cmd);
if (len > maxlen) maxlen = len;
curr = g_list_next(curr);
}
} else if (strcmp(args[0], "contacts") == 0) {
gchar *filter[] = { "/group", "/roster", "/sub", "/who" };
_cmd_show_filtered_help("Roster commands", filter, ARRAY_SIZE(filter));
} else if (strcmp(args[0], "service") == 0) {
gchar *filter[] = { "/caps", "/disco", "/info", "/software", "/rooms" };
_cmd_show_filtered_help("Service discovery commands", filter, ARRAY_SIZE(filter));
} else if (strcmp(args[0], "settings") == 0) {
gchar *filter[] = { "/account", "/autoaway", "/autoping", "/autoconnect", "/beep",
"/carbons", "/chlog", "/flash", "/gone", "/grlog", "/history", "/intype",
"/log", "/notify", "/outtype", "/prefs", "/priority", "/reconnect", "/roster",
"/splash", "/states", "/statuses", "/theme", "/titlebar", "/vercheck",
"/privileges", "/occupants", "/presence", "/wrap", "/winstidy" };
_cmd_show_filtered_help("Settings commands", filter, ARRAY_SIZE(filter));
GString *cmds = g_string_new("");
curr = ordered_commands;
int count = 0;
while (curr) {
gchar *cmd = curr->data;
if (count == 5) {
cons_show(cmds->str);
g_string_free(cmds, TRUE);
cmds = g_string_new("");
count = 0;
}
g_string_append_printf(cmds, "%-*s", maxlen + 1, cmd);
curr = g_list_next(curr);
count++;
}
cons_show(cmds->str);
g_string_free(cmds, TRUE);
g_list_free(ordered_commands);
g_list_free(curr);
cons_show("");
cons_show("Use /help [command] without the leading slash, for help on a specific command");
cons_show("");
} else if (strcmp(args[0], "navigation") == 0) {
cons_navigation_help();
} else {
@ -4743,50 +4793,50 @@ _cmd_set_boolean_preference(gchar *arg, const char * const command,
return TRUE;
}
static void
_cmd_show_filtered_help(char *heading, gchar *cmd_filter[], int filter_size)
{
ProfWin *console = wins_get_console();
cons_show("");
win_print(console, '-', NULL, 0, THEME_WHITE_BOLD, "", heading);
GList *ordered_commands = NULL;
int i;
for (i = 0; i < filter_size; i++) {
Command *pcmd = g_hash_table_lookup(commands, cmd_filter[i]);
ordered_commands = g_list_insert_sorted(ordered_commands, pcmd->cmd, (GCompareFunc)g_strcmp0);
}
int maxlen = 0;
GList *curr = ordered_commands;
while (curr) {
gchar *cmd = curr->data;
int len = strlen(cmd);
if (len > maxlen) maxlen = len;
curr = g_list_next(curr);
}
GString *cmds = g_string_new("");
curr = ordered_commands;
int count = 0;
while (curr) {
gchar *cmd = curr->data;
if (count == 5) {
cons_show(cmds->str);
g_string_free(cmds, TRUE);
cmds = g_string_new("");
count = 0;
}
g_string_append_printf(cmds, "%-*s", maxlen + 1, cmd);
curr = g_list_next(curr);
count++;
}
cons_show(cmds->str);
g_string_free(cmds, TRUE);
g_list_free(ordered_commands);
g_list_free(curr);
cons_show("");
cons_show("Use /help [command] without the leading slash, for help on a specific command");
cons_show("");
}
//static void
//_cmd_show_filtered_help(char *heading, gchar *cmd_filter[], int filter_size)
//{
// ProfWin *console = wins_get_console();
// cons_show("");
// win_print(console, '-', NULL, 0, THEME_WHITE_BOLD, "", heading);
//
// GList *ordered_commands = NULL;
// int i;
// for (i = 0; i < filter_size; i++) {
// Command *pcmd = g_hash_table_lookup(commands, cmd_filter[i]);
// ordered_commands = g_list_insert_sorted(ordered_commands, pcmd->cmd, (GCompareFunc)g_strcmp0);
// }
//
// int maxlen = 0;
// GList *curr = ordered_commands;
// while (curr) {
// gchar *cmd = curr->data;
// int len = strlen(cmd);
// if (len > maxlen) maxlen = len;
// curr = g_list_next(curr);
// }
//
// GString *cmds = g_string_new("");
// curr = ordered_commands;
// int count = 0;
// while (curr) {
// gchar *cmd = curr->data;
// if (count == 5) {
// cons_show(cmds->str);
// g_string_free(cmds, TRUE);
// cmds = g_string_new("");
// count = 0;
// }
// g_string_append_printf(cmds, "%-*s", maxlen + 1, cmd);
// curr = g_list_next(curr);
// count++;
// }
// cons_show(cmds->str);
// g_string_free(cmds, TRUE);
// g_list_free(ordered_commands);
// g_list_free(curr);
//
// cons_show("");
// cons_show("Use /help [command] without the leading slash, for help on a specific command");
// cons_show("");
//}

View File

@ -39,6 +39,7 @@
// Command help strings
typedef struct cmd_help_t {
const gchar *tags[20];
const gchar *synopsis[50];
const gchar *desc;
const gchar *args[50][2];

View File

@ -1542,6 +1542,7 @@ cons_help(void)
cons_show("/help contacts - List commands for manipulating your roster.");
cons_show("/help service - List service discovery commands.");
cons_show("/help settings - List commands for changing settings.");
cons_show("/help ui - List commands for configuring the user interface.");
cons_show("/help navigation - How to navigate around Profanity.");
cons_show("/help [command] - Detailed help on a specific command.");
cons_show("");