1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-09-29 19:56:07 -04:00

Moved help and about to new format

This commit is contained in:
James Booth 2015-07-23 23:05:33 +01:00
parent 3985f22250
commit 22111bf75b
6 changed files with 244 additions and 111 deletions

View File

@ -109,30 +109,41 @@ GHashTable *commands = NULL;
*/ */
static struct cmd_t command_defs[] = static struct cmd_t command_defs[] =
{ {
{ "/help", // NEW STYLE
cmd_help, parse_args, 0, 1, NULL, { "/help", cmd_help, parse_args, 0, 1, NULL,
{ "/help [area|command]", "Help on using Profanity.", { NULL, NULL, { NULL },
{ "/help [area|command]", {
"--------------------", "/help [<area>|<command>]",
"Help on using Profanity.", NULL },
"",
"area : Summary help for commands in a certain area of functionality.",
"command : Full help for a specific command, for example '/help connect'.",
"",
"Use with no arguments to see a list of areas.",
"",
"Example: /help commands",
"Example: /help presence",
"Example: /help who",
NULL } } },
{ "/about", "Help on using Profanity. Passing no arguments list help areas.",
cmd_about, parse_args, 0, 0, NULL,
{ "/about", "About Profanity.", {
{ "/about", { "area", "Summary help for commands in a certain area of functionality." },
"------", { "command", "Full help for a specific command, for example '/help connect'." },
"Show version and license information.", { NULL, NULL } },
NULL } } },
{
"/help commands",
"/help presence",
"/help who",
NULL } } },
{ "/about", cmd_about, parse_args, 0, 0, NULL,
{ NULL, NULL, { NULL },
{
"/about",
NULL },
"Show version and license information.",
{
{ NULL, NULL } },
{
NULL } } },
// OLD STYLE
{ "/connect", { "/connect",
cmd_connect, parse_args, 0, 5, NULL, cmd_connect, parse_args, 0, 5, NULL,
@ -153,7 +164,8 @@ static struct cmd_t command_defs[] =
"Example: /connect myuser@mycompany.com server talk.google.com", "Example: /connect myuser@mycompany.com server talk.google.com",
"Example: /connect bob@someplace port 5678", "Example: /connect bob@someplace port 5678",
"Example: /connect me@chatty server chatty.com port 5443", "Example: /connect me@chatty server chatty.com port 5443",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/disconnect", { "/disconnect",
cmd_disconnect, parse_args, 0, 0, NULL, cmd_disconnect, parse_args, 0, 0, NULL,
@ -161,7 +173,8 @@ static struct cmd_t command_defs[] =
{ "/disconnect", { "/disconnect",
"-----------", "-----------",
"Disconnect from the current chat service.", "Disconnect from the current chat service.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/msg", { "/msg",
cmd_msg, parse_args_with_freetext, 1, 2, NULL, cmd_msg, parse_args_with_freetext, 1, 2, NULL,
@ -181,7 +194,8 @@ static struct cmd_t command_defs[] =
"Example: /msg otherfriend@server.com", "Example: /msg otherfriend@server.com",
"Example: /msg Bob Here is a private message", "Example: /msg Bob Here is a private message",
"Example: /msg \"My Friend\" Hi, how are you?", "Example: /msg \"My Friend\" Hi, how are you?",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/roster", { "/roster",
cmd_roster, parse_args_with_freetext, 0, 3, NULL, cmd_roster, parse_args_with_freetext, 0, 3, NULL,
@ -219,7 +233,8 @@ static struct cmd_t command_defs[] =
"Example: /roster remove someone@contacts.org (remove the contact)", "Example: /roster remove someone@contacts.org (remove the contact)",
"Example: /roster nick myfriend@chat.org My Friend", "Example: /roster nick myfriend@chat.org My Friend",
"Example: /roster clearnick kai@server.com (clears nickname)", "Example: /roster clearnick kai@server.com (clears nickname)",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/group", { "/group",
cmd_group, parse_args_with_freetext, 0, 3, NULL, cmd_group, parse_args_with_freetext, 0, 3, NULL,
@ -239,7 +254,8 @@ static struct cmd_t command_defs[] =
"Example: /group add friends newfriend@server.org", "Example: /group add friends newfriend@server.org",
"Example: /group add family Brother (using contacts nickname)", "Example: /group add family Brother (using contacts nickname)",
"Example: /group remove colleagues boss@work.com", "Example: /group remove colleagues boss@work.com",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/info", { "/info",
cmd_info, parse_args, 0, 1, NULL, cmd_info, parse_args, 0, 1, NULL,
@ -256,7 +272,8 @@ static struct cmd_t command_defs[] =
"", "",
"Example: /info mybuddy@chat.server.org", "Example: /info mybuddy@chat.server.org",
"Example: /info kai", "Example: /info kai",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/caps", { "/caps",
cmd_caps, parse_args, 0, 1, NULL, cmd_caps, parse_args, 0, 1, NULL,
@ -273,7 +290,8 @@ static struct cmd_t command_defs[] =
"Example: /caps mybuddy@chat.server.org/laptop (contact's laptop resource)", "Example: /caps mybuddy@chat.server.org/laptop (contact's laptop resource)",
"Example: /caps mybuddy@chat.server.org/phone (contact's phone resource)", "Example: /caps mybuddy@chat.server.org/phone (contact's phone resource)",
"Example: /caps bruce (room member)", "Example: /caps bruce (room member)",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/software", { "/software",
cmd_software, parse_args, 0, 1, NULL, cmd_software, parse_args, 0, 1, NULL,
@ -291,7 +309,8 @@ static struct cmd_t command_defs[] =
"Example: /software mybuddy@chat.server.org/laptop (contact's laptop resource)", "Example: /software mybuddy@chat.server.org/laptop (contact's laptop resource)",
"Example: /software mybuddy@chat.server.org/phone (contact's phone resource)", "Example: /software mybuddy@chat.server.org/phone (contact's phone resource)",
"Example: /software bruce (room member)", "Example: /software bruce (room member)",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/status", { "/status",
cmd_status, parse_args, 0, 1, NULL, cmd_status, parse_args, 0, 1, NULL,
@ -307,7 +326,8 @@ static struct cmd_t command_defs[] =
"", "",
"Example: /status buddy@server.com", "Example: /status buddy@server.com",
"Example: /status jon", "Example: /status jon",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/resource", { "/resource",
cmd_resource, parse_args, 1, 2, &cons_resource_setting, cmd_resource, parse_args, 1, 2, &cons_resource_setting,
@ -320,7 +340,8 @@ static struct cmd_t command_defs[] =
"off : Let the server choose which resource to route messages to.", "off : Let the server choose which resource to route messages to.",
"title on|off : Show or hide the current resource in the titlebar.", "title on|off : Show or hide the current resource in the titlebar.",
"message on|off : Show or hide the resource when showing an incoming message.", "message on|off : Show or hide the resource when showing an incoming message.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/join", { "/join",
cmd_join, parse_args, 0, 5, NULL, cmd_join, parse_args, 0, 5, NULL,
@ -342,7 +363,8 @@ static struct cmd_t command_defs[] =
"Example: /join jdev@conference.jabber.org nick mynick", "Example: /join jdev@conference.jabber.org nick mynick",
"Example: /join private@conference.jabber.org nick mynick password mypassword", "Example: /join private@conference.jabber.org nick mynick password mypassword",
"Example: /join jdev (as user@jabber.org will join jdev@conference.jabber.org)", "Example: /join jdev (as user@jabber.org will join jdev@conference.jabber.org)",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/leave", { "/leave",
cmd_leave, parse_args, 0, 0, NULL, cmd_leave, parse_args, 0, 0, NULL,
@ -350,7 +372,8 @@ static struct cmd_t command_defs[] =
{ "/leave", { "/leave",
"------", "------",
"Leave the current chat room.", "Leave the current chat room.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/invite", { "/invite",
cmd_invite, parse_args_with_freetext, 1, 2, NULL, cmd_invite, parse_args_with_freetext, 1, 2, NULL,
@ -361,7 +384,8 @@ static struct cmd_t command_defs[] =
"", "",
"contact : The contact you wish to invite", "contact : The contact you wish to invite",
"message : An optional message to send with the invite.", "message : An optional message to send with the invite.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/invites", { "/invites",
cmd_invites, parse_args_with_freetext, 0, 0, NULL, cmd_invites, parse_args_with_freetext, 0, 0, NULL,
@ -369,7 +393,8 @@ static struct cmd_t command_defs[] =
{ "/invites", { "/invites",
"--------", "--------",
"Show all rooms that you have been invited to, and not accepted or declined.", "Show all rooms that you have been invited to, and not accepted or declined.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/decline", { "/decline",
cmd_decline, parse_args_with_freetext, 1, 1, NULL, cmd_decline, parse_args_with_freetext, 1, 1, NULL,
@ -379,7 +404,8 @@ static struct cmd_t command_defs[] =
"Decline a chat room invitation.", "Decline a chat room invitation.",
"", "",
"room : The room for the invite you wish to decline.", "room : The room for the invite you wish to decline.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/room", { "/room",
cmd_room, parse_args, 1, 1, NULL, cmd_room, parse_args, 1, 1, NULL,
@ -391,7 +417,8 @@ static struct cmd_t command_defs[] =
"accept : Accept default room configuration.", "accept : Accept default room configuration.",
"destroy : Reject default room configuration.", "destroy : Reject default room configuration.",
"config : Edit room configuration.", "config : Edit room configuration.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/kick", { "/kick",
cmd_kick, parse_args_with_freetext, 1, 2, NULL, cmd_kick, parse_args_with_freetext, 1, 2, NULL,
@ -402,7 +429,8 @@ static struct cmd_t command_defs[] =
"", "",
"nick : Nickname of the occupant to kick from the room.", "nick : Nickname of the occupant to kick from the room.",
"reason : Optional reason for kicking the occupant.", "reason : Optional reason for kicking the occupant.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/ban", { "/ban",
cmd_ban, parse_args_with_freetext, 1, 2, NULL, cmd_ban, parse_args_with_freetext, 1, 2, NULL,
@ -413,7 +441,8 @@ static struct cmd_t command_defs[] =
"", "",
"jid : Bare JID of the user to ban from the room.", "jid : Bare JID of the user to ban from the room.",
"reason : Optional reason for banning the user.", "reason : Optional reason for banning the user.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/subject", { "/subject",
cmd_subject, parse_args_with_freetext, 0, 2, NULL, cmd_subject, parse_args_with_freetext, 0, 2, NULL,
@ -424,7 +453,8 @@ static struct cmd_t command_defs[] =
"", "",
"set subject : Set the room subject.", "set subject : Set the room subject.",
"clear : Clear the room subject.", "clear : Clear the room subject.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/affiliation", { "/affiliation",
cmd_affiliation, parse_args_with_freetext, 1, 4, NULL, cmd_affiliation, parse_args_with_freetext, 1, 4, NULL,
@ -437,7 +467,8 @@ static struct cmd_t command_defs[] =
"list [affiliation] : List all users with the specified affiliation, or all if none specified.", "list [affiliation] : List all users with the specified affiliation, or all if none specified.",
"", "",
"The affiliation may be one of owner, admin, member, outcast or none.", "The affiliation may be one of owner, admin, member, outcast or none.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/role", { "/role",
cmd_role, parse_args_with_freetext, 1, 4, NULL, cmd_role, parse_args_with_freetext, 1, 4, NULL,
@ -450,7 +481,8 @@ static struct cmd_t command_defs[] =
"list [role] : List all occupants with the specified role, or all if none specified.", "list [role] : List all occupants with the specified role, or all if none specified.",
"", "",
"The role may be one of moderator, participant, visitor or none.", "The role may be one of moderator, participant, visitor or none.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/occupants", { "/occupants",
cmd_occupants, parse_args, 1, 3, cons_occupants_setting, cmd_occupants, parse_args, 1, 3, cons_occupants_setting,
@ -466,7 +498,8 @@ static struct cmd_t command_defs[] =
"default show|hide : Whether occupants are shown by default in new rooms.", "default show|hide : Whether occupants are shown by default in new rooms.",
"default show|hide jid : Whether occupants jids are shown by default in new rooms.", "default show|hide jid : Whether occupants jids are shown by default in new rooms.",
"size percent : Percentage of the screen taken by the occupants list in rooms (1-99).", "size percent : Percentage of the screen taken by the occupants list in rooms (1-99).",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/form", { "/form",
cmd_form, parse_args, 1, 2, NULL, cmd_form, parse_args, 1, 2, NULL,
@ -479,7 +512,8 @@ static struct cmd_t command_defs[] =
"submit : Submit the current form.", "submit : Submit the current form.",
"cancel : Cancel changes to the current form.", "cancel : Cancel changes to the current form.",
"help [tag] : Display help for form, or a specific field.", "help [tag] : Display help for form, or a specific field.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/rooms", { "/rooms",
cmd_rooms, parse_args, 0, 1, NULL, cmd_rooms, parse_args, 0, 1, NULL,
@ -494,7 +528,8 @@ static struct cmd_t command_defs[] =
"", "",
"Example: /rooms conference.jabber.org", "Example: /rooms conference.jabber.org",
"Example: /rooms (if logged in as me@server.org, is equivalent to /rooms conference.server.org)", "Example: /rooms (if logged in as me@server.org, is equivalent to /rooms conference.server.org)",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/bookmark", { "/bookmark",
cmd_bookmark, parse_args, 0, 8, NULL, cmd_bookmark, parse_args, 0, 8, NULL,
@ -515,7 +550,8 @@ static struct cmd_t command_defs[] =
"join room@server : Join room using the properties associated with the bookmark.", "join room@server : Join room using the properties associated with the bookmark.",
"", "",
"In a chat room, /bookmark with no arguments will bookmark the current room, setting autojoin to \"on\".", "In a chat room, /bookmark with no arguments will bookmark the current room, setting autojoin to \"on\".",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/disco", { "/disco",
cmd_disco, parse_args, 1, 2, NULL, cmd_disco, parse_args, 1, 2, NULL,
@ -532,7 +568,8 @@ static struct cmd_t command_defs[] =
"Example: /disco items myserver.org", "Example: /disco items myserver.org",
"Example: /disco items conference.jabber.org", "Example: /disco items conference.jabber.org",
"Example: /disco info myfriend@server.com/laptop", "Example: /disco info myfriend@server.com/laptop",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/nick", { "/nick",
cmd_nick, parse_args_with_freetext, 1, 1, NULL, cmd_nick, parse_args_with_freetext, 1, 1, NULL,
@ -545,7 +582,8 @@ static struct cmd_t command_defs[] =
"", "",
"Example: /nick kai hansen", "Example: /nick kai hansen",
"Example: /nick bob", "Example: /nick bob",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/win", { "/win",
cmd_win, parse_args, 1, 1, NULL, cmd_win, parse_args, 1, 1, NULL,
@ -555,7 +593,8 @@ static struct cmd_t command_defs[] =
"Show the contents of a specific window in the main window area.", "Show the contents of a specific window in the main window area.",
"", "",
"num - Window number to display.", "num - Window number to display.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/wins", { "/wins",
cmd_wins, parse_args, 0, 3, NULL, cmd_wins, parse_args, 0, 3, NULL,
@ -569,7 +608,8 @@ static struct cmd_t command_defs[] =
"swap source target : Swap windows, target may be an empty position.", "swap source target : Swap windows, target may be an empty position.",
"", "",
"Passing no argument will list all currently active windows and information about their usage.", "Passing no argument will list all currently active windows and information about their usage.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/sub", { "/sub",
cmd_sub, parse_args, 1, 2, NULL, cmd_sub, parse_args, 1, 2, NULL,
@ -591,7 +631,8 @@ static struct cmd_t command_defs[] =
"Example: /sub allow myfriend@jabber.org", "Example: /sub allow myfriend@jabber.org",
"Example: /sub request (whilst in chat with contact)", "Example: /sub request (whilst in chat with contact)",
"Example: /sub sent", "Example: /sub sent",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/tiny", { "/tiny",
cmd_tiny, parse_args, 1, 1, NULL, cmd_tiny, parse_args, 1, 1, NULL,
@ -603,7 +644,8 @@ static struct cmd_t command_defs[] =
"url : The url to make tiny.", "url : The url to make tiny.",
"", "",
"Example: /tiny http://www.profanity.im", "Example: /tiny http://www.profanity.im",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/who", { "/who",
cmd_who, parse_args, 0, 2, NULL, cmd_who, parse_args, 0, 2, NULL,
@ -620,7 +662,8 @@ static struct cmd_t command_defs[] =
"role : moderator|participant|visitor", "role : moderator|participant|visitor",
"affiliation : owner|admin|member", "affiliation : owner|admin|member",
"group : Filter the results by the specified group.", "group : Filter the results by the specified group.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/close", { "/close",
cmd_close, parse_args, 0, 1, NULL, cmd_close, parse_args, 0, 1, NULL,
@ -634,7 +677,8 @@ static struct cmd_t command_defs[] =
"read : Close all windows that have no new messages.", "read : Close all windows that have no new messages.",
"", "",
"Passing no argument will close the current window.", "Passing no argument will close the current window.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/clear", { "/clear",
cmd_clear, parse_args, 0, 0, NULL, cmd_clear, parse_args, 0, 0, NULL,
@ -642,7 +686,8 @@ static struct cmd_t command_defs[] =
{ "/clear", { "/clear",
"------", "------",
"Clear the current window.", "Clear the current window.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/quit", { "/quit",
cmd_quit, parse_args, 0, 0, NULL, cmd_quit, parse_args, 0, 0, NULL,
@ -650,7 +695,8 @@ static struct cmd_t command_defs[] =
{ "/quit", { "/quit",
"-----", "-----",
"Logout of any current session, and quit Profanity.", "Logout of any current session, and quit Profanity.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/privileges", { "/privileges",
cmd_privileges, parse_args, 1, 1, &cons_privileges_setting, cmd_privileges, parse_args, 1, 1, &cons_privileges_setting,
@ -658,7 +704,8 @@ static struct cmd_t command_defs[] =
{ "/privileges on|off", { "/privileges on|off",
"------------------", "------------------",
"If enabled the room occupants panel will be grouped by role, and role information will be shown in the room.", "If enabled the room occupants panel will be grouped by role, and role information will be shown in the room.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/beep", { "/beep",
cmd_beep, parse_args, 1, 1, &cons_beep_setting, cmd_beep, parse_args, 1, 1, &cons_beep_setting,
@ -668,7 +715,8 @@ static struct cmd_t command_defs[] =
"Switch the terminal bell on or off.", "Switch the terminal bell on or off.",
"The bell will sound when incoming messages are received.", "The bell will sound when incoming messages are received.",
"If the terminal does not support sounds, it may attempt to flash the screen instead.", "If the terminal does not support sounds, it may attempt to flash the screen instead.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/encwarn", { "/encwarn",
cmd_encwarn, parse_args, 1, 1, &cons_encwarn_setting, cmd_encwarn, parse_args, 1, 1, &cons_encwarn_setting,
@ -676,7 +724,8 @@ static struct cmd_t command_defs[] =
{ "/encwarn on|off", { "/encwarn on|off",
"---------------", "---------------",
"Enabled or disable the unencrypted warning message in the titlebar.", "Enabled or disable the unencrypted warning message in the titlebar.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/presence", { "/presence",
cmd_presence, parse_args, 1, 1, &cons_presence_setting, cmd_presence, parse_args, 1, 1, &cons_presence_setting,
@ -684,7 +733,8 @@ static struct cmd_t command_defs[] =
{ "/presence on|off", { "/presence on|off",
"----------------", "----------------",
"Switch display of the contacts presence in the titlebar on or off.", "Switch display of the contacts presence in the titlebar on or off.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/wrap", { "/wrap",
cmd_wrap, parse_args, 1, 1, &cons_wrap_setting, cmd_wrap, parse_args, 1, 1, &cons_wrap_setting,
@ -692,7 +742,8 @@ static struct cmd_t command_defs[] =
{ "/wrap on|off", { "/wrap on|off",
"------------", "------------",
"Enable or disable word wrapping in the main window.", "Enable or disable word wrapping in the main window.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/winstidy", { "/winstidy",
cmd_winstidy, parse_args, 1, 1, &cons_winstidy_setting, cmd_winstidy, parse_args, 1, 1, &cons_winstidy_setting,
@ -700,7 +751,8 @@ static struct cmd_t command_defs[] =
{ "/winstidy on|off", { "/winstidy on|off",
"----------------", "----------------",
"Enable or disable auto window tidy.", "Enable or disable auto window tidy.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/time", { "/time",
cmd_time, parse_args, 1, 3, &cons_time_setting, cmd_time, parse_args, 1, 3, &cons_time_setting,
@ -718,7 +770,8 @@ static struct cmd_t command_defs[] =
"See https://developer.gnome.org/glib/stable/glib-GDateTime.html#g-date-time-format for more details.", "See https://developer.gnome.org/glib/stable/glib-GDateTime.html#g-date-time-format for more details.",
"Example: /time main set %H:%M (main time will be set to HH:MM)", "Example: /time main set %H:%M (main time will be set to HH:MM)",
"Example: /time statusbar set yolo (statusbar time will all be changed to a static yolo)", "Example: /time statusbar set yolo (statusbar time will all be changed to a static yolo)",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/inpblock", { "/inpblock",
cmd_inpblock, parse_args, 2, 2, &cons_inpblock_setting, cmd_inpblock, parse_args, 2, 2, &cons_inpblock_setting,
@ -729,7 +782,8 @@ static struct cmd_t command_defs[] =
"", "",
"timeout millis : Time to wait (1-1000) in milliseconds before reading input from the terminal buffer, default: 1000.", "timeout millis : Time to wait (1-1000) in milliseconds before reading input from the terminal buffer, default: 1000.",
"dynamic on|off : Start with 0 millis and dynamically increase up to timeout when no activity, default: on.", "dynamic on|off : Start with 0 millis and dynamically increase up to timeout when no activity, default: on.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/notify", { "/notify",
cmd_notify, parse_args, 2, 3, &cons_notify_setting, cmd_notify, parse_args, 2, 3, &cons_notify_setting,
@ -759,7 +813,8 @@ static struct cmd_t command_defs[] =
"Example: /notify remind 0 (switch off reminders)", "Example: /notify remind 0 (switch off reminders)",
"Example: /notify typing on (enable typing notifications)", "Example: /notify typing on (enable typing notifications)",
"Example: /notify invite on (enable chat room invite notifications)", "Example: /notify invite on (enable chat room invite notifications)",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/flash", { "/flash",
cmd_flash, parse_args, 1, 1, &cons_flash_setting, cmd_flash, parse_args, 1, 1, &cons_flash_setting,
@ -768,7 +823,8 @@ static struct cmd_t command_defs[] =
"-------------", "-------------",
"Make the terminal flash when incoming messages are received in another window.", "Make the terminal flash when incoming messages are received in another window.",
"If the terminal doesn't support flashing, it may attempt to beep.", "If the terminal doesn't support flashing, it may attempt to beep.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/intype", { "/intype",
cmd_intype, parse_args, 1, 1, &cons_intype_setting, cmd_intype, parse_args, 1, 1, &cons_intype_setting,
@ -776,7 +832,8 @@ static struct cmd_t command_defs[] =
{ "/intype on|off", { "/intype on|off",
"--------------", "--------------",
"Show when a contact is typing in the console, and in active message window.", "Show when a contact is typing in the console, and in active message window.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/splash", { "/splash",
cmd_splash, parse_args, 1, 1, &cons_splash_setting, cmd_splash, parse_args, 1, 1, &cons_splash_setting,
@ -784,7 +841,8 @@ static struct cmd_t command_defs[] =
{ "/splash on|off", { "/splash on|off",
"--------------", "--------------",
"Switch on or off the ascii logo on start up and when the /about command is called.", "Switch on or off the ascii logo on start up and when the /about command is called.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/autoconnect", { "/autoconnect",
cmd_autoconnect, parse_args, 1, 2, &cons_autoconnect_setting, cmd_autoconnect, parse_args, 1, 2, &cons_autoconnect_setting,
@ -796,7 +854,8 @@ static struct cmd_t command_defs[] =
"", "",
"Example: /autoconnect set jc@stuntteam.org (autoconnect with the specified account).", "Example: /autoconnect set jc@stuntteam.org (autoconnect with the specified account).",
"Example: /autoconnect off (disable autoconnect).", "Example: /autoconnect off (disable autoconnect).",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/vercheck", { "/vercheck",
cmd_vercheck, parse_args, 0, 1, NULL, cmd_vercheck, parse_args, 0, 1, NULL,
@ -804,7 +863,8 @@ static struct cmd_t command_defs[] =
{ "/vercheck [on|off]", { "/vercheck [on|off]",
"------------------", "------------------",
"Enable/disable a version check when Profanity starts, and each time the /about command is run.", "Enable/disable a version check when Profanity starts, and each time the /about command is run.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/titlebar", { "/titlebar",
cmd_titlebar, parse_args, 2, 2, &cons_titlebar_setting, cmd_titlebar, parse_args, 2, 2, &cons_titlebar_setting,
@ -815,7 +875,8 @@ static struct cmd_t command_defs[] =
"", "",
"show : Show current logged in user, and unread messages in the title.", "show : Show current logged in user, and unread messages in the title.",
"goodbye : Show a message in the title when exiting profanity.", "goodbye : Show a message in the title when exiting profanity.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/alias", { "/alias",
cmd_alias, parse_args_with_freetext, 1, 3, NULL, cmd_alias, parse_args_with_freetext, 1, 3, NULL,
@ -835,7 +896,8 @@ static struct cmd_t command_defs[] =
"Example: /alias list", "Example: /alias list",
"", "",
"The above aliases will be available as /friends and /a", "The above aliases will be available as /friends and /a",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/chlog", { "/chlog",
cmd_chlog, parse_args, 1, 1, &cons_chlog_setting, cmd_chlog, parse_args, 1, 1, &cons_chlog_setting,
@ -846,7 +908,8 @@ static struct cmd_t command_defs[] =
"This setting will be enabled if /history is set to on.", "This setting will be enabled if /history is set to on.",
"When disabling this option, /history will also be disabled.", "When disabling this option, /history will also be disabled.",
"See the /grlog setting for enabling logging of chat room (groupchat) messages.", "See the /grlog setting for enabling logging of chat room (groupchat) messages.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/grlog", { "/grlog",
cmd_grlog, parse_args, 1, 1, &cons_grlog_setting, cmd_grlog, parse_args, 1, 1, &cons_grlog_setting,
@ -855,7 +918,8 @@ static struct cmd_t command_defs[] =
"-------------", "-------------",
"Switch chat room logging on or off.", "Switch chat room logging on or off.",
"See the /chlog setting for enabling logging of one to one chat.", "See the /chlog setting for enabling logging of one to one chat.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/states", { "/states",
cmd_states, parse_args, 1, 1, &cons_states_setting, cmd_states, parse_args, 1, 1, &cons_states_setting,
@ -863,7 +927,8 @@ static struct cmd_t command_defs[] =
{ "/states on|off", { "/states on|off",
"--------------", "--------------",
"Send chat state notifications during chat sessions.", "Send chat state notifications during chat sessions.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/pgp", { "/pgp",
cmd_pgp, parse_args, 1, 3, NULL, cmd_pgp, parse_args, 1, 3, NULL,
@ -879,7 +944,8 @@ static struct cmd_t command_defs[] =
"start [contact] : Start PGP encrypted chat, current contact will be used if not specified.", "start [contact] : Start PGP encrypted chat, current contact will be used if not specified.",
"end : End PGP encrypted chat with the current recipient.", "end : End PGP encrypted chat with the current recipient.",
"log on|off|redact : PGP message logging, default: redact.", "log on|off|redact : PGP message logging, default: redact.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/otr", { "/otr",
cmd_otr, parse_args, 1, 3, NULL, cmd_otr, parse_args, 1, 3, NULL,
@ -902,7 +968,8 @@ static struct cmd_t command_defs[] =
"secret [secret] : Verify a contacts identity using a shared secret.", "secret [secret] : Verify a contacts identity using a shared secret.",
"question [question] [answer] : Verify a contacts identity using a question and expected answer.", "question [question] [answer] : Verify a contacts identity using a question and expected answer.",
"answer [answer] : Respond to a question answer verification request with your answer.", "answer [answer] : Respond to a question answer verification request with your answer.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/outtype", { "/outtype",
cmd_outtype, parse_args, 1, 1, &cons_outtype_setting, cmd_outtype, parse_args, 1, 1, &cons_outtype_setting,
@ -910,7 +977,8 @@ static struct cmd_t command_defs[] =
{ "/outtype on|off", { "/outtype on|off",
"---------------", "---------------",
"Send typing notifications, chat states (/states) will be enabled if this setting is set.", "Send typing notifications, chat states (/states) will be enabled if this setting is set.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/gone", { "/gone",
cmd_gone, parse_args, 1, 1, &cons_gone_setting, cmd_gone, parse_args, 1, 1, &cons_gone_setting,
@ -920,7 +988,8 @@ static struct cmd_t command_defs[] =
"Send a 'gone' state to the recipient after the specified number of minutes.", "Send a 'gone' state to the recipient after the specified number of minutes.",
"A value of 0 will disable sending this chat state.", "A value of 0 will disable sending this chat state.",
"Chat states (/states) will be enabled if this setting is set.", "Chat states (/states) will be enabled if this setting is set.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/history", { "/history",
cmd_history, parse_args, 1, 1, &cons_history_setting, cmd_history, parse_args, 1, 1, &cons_history_setting,
@ -929,7 +998,8 @@ static struct cmd_t command_defs[] =
"---------------", "---------------",
"Switch chat history on or off, /chlog will automatically be enabled when this setting is on.", "Switch chat history on or off, /chlog will automatically be enabled when this setting is on.",
"When history is enabled, previous messages are shown in chat windows.", "When history is enabled, previous messages are shown in chat windows.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/log", { "/log",
cmd_log, parse_args, 1, 2, &cons_log_setting, cmd_log, parse_args, 1, 2, &cons_log_setting,
@ -942,7 +1012,8 @@ static struct cmd_t command_defs[] =
"rotate on|off : Rotate log, default on.", "rotate on|off : Rotate log, default on.",
"maxsize bytes : With rotate enabled, specifies the max log size, defaults to 1048580 (1MB).", "maxsize bytes : With rotate enabled, specifies the max log size, defaults to 1048580 (1MB).",
"shared on|off : Share logs between all instances, default: on.", "shared on|off : Share logs between all instances, default: on.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/carbons", { "/carbons",
cmd_carbons, parse_args, 1, 1, &cons_carbons_setting, cmd_carbons, parse_args, 1, 1, &cons_carbons_setting,
@ -951,7 +1022,8 @@ static struct cmd_t command_defs[] =
"---------------", "---------------",
"Enable or disable message carbons.", "Enable or disable message carbons.",
"The message carbons feature ensures that both sides of all conversations are shared with all the user's clients that implement this protocol.", "The message carbons feature ensures that both sides of all conversations are shared with all the user's clients that implement this protocol.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/receipts", { "/receipts",
cmd_receipts, parse_args, 2, 2, &cons_receipts_setting, cmd_receipts, parse_args, 2, 2, &cons_receipts_setting,
@ -962,7 +1034,8 @@ static struct cmd_t command_defs[] =
"", "",
"send on|off : Enable or disable sending of delivery receipts.", "send on|off : Enable or disable sending of delivery receipts.",
"request on|off : Enable or disable sending of delivery receipt requests.", "request on|off : Enable or disable sending of delivery receipt requests.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/reconnect", { "/reconnect",
cmd_reconnect, parse_args, 1, 1, &cons_reconnect_setting, cmd_reconnect, parse_args, 1, 1, &cons_reconnect_setting,
@ -971,7 +1044,8 @@ static struct cmd_t command_defs[] =
"------------------", "------------------",
"Set the reconnect attempt interval in seconds for when the connection is lost.", "Set the reconnect attempt interval in seconds for when the connection is lost.",
"A value of 0 will switch off reconnect attempts.", "A value of 0 will switch off reconnect attempts.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/autoping", { "/autoping",
cmd_autoping, parse_args, 1, 1, &cons_autoping_setting, cmd_autoping, parse_args, 1, 1, &cons_autoping_setting,
@ -980,7 +1054,8 @@ static struct cmd_t command_defs[] =
"-----------------", "-----------------",
"Set the number of seconds between server pings, so ensure connection kept alive.", "Set the number of seconds between server pings, so ensure connection kept alive.",
"A value of 0 will switch off autopinging the server.", "A value of 0 will switch off autopinging the server.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/ping", { "/ping",
cmd_ping, parse_args, 0, 1, NULL, cmd_ping, parse_args, 0, 1, NULL,
@ -989,7 +1064,8 @@ static struct cmd_t command_defs[] =
"--------------", "--------------",
"Sends an IQ ping stanza to the specified target.", "Sends an IQ ping stanza to the specified target.",
"If no target is supplied, your chat server will be pinged.", "If no target is supplied, your chat server will be pinged.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/autoaway", { "/autoaway",
cmd_autoaway, parse_args_with_freetext, 2, 2, &cons_autoaway_setting, cmd_autoaway, parse_args_with_freetext, 2, 2, &cons_autoaway_setting,
@ -1009,7 +1085,8 @@ static struct cmd_t command_defs[] =
"Example: /autoaway time 30", "Example: /autoaway time 30",
"Example: /autoaway message I'm not really doing much", "Example: /autoaway message I'm not really doing much",
"Example: /autoaway check off", "Example: /autoaway check off",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/priority", { "/priority",
cmd_priority, parse_args, 1, 1, &cons_priority_setting, cmd_priority, parse_args, 1, 1, &cons_priority_setting,
@ -1021,7 +1098,8 @@ static struct cmd_t command_defs[] =
"value : Number between -128 and 127, default: 0.", "value : Number between -128 and 127, default: 0.",
"", "",
"See the /account command for specific priority settings per presence status.", "See the /account command for specific priority settings per presence status.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/account", { "/account",
cmd_account, parse_args, 0, 4, NULL, cmd_account, parse_args, 0, 4, NULL,
@ -1064,7 +1142,8 @@ static struct cmd_t command_defs[] =
"Example: /account set me status dnd", "Example: /account set me status dnd",
"Example: /account set me dnd -1", "Example: /account set me dnd -1",
"Example: /account rename me gtalk", "Example: /account rename me gtalk",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/prefs", { "/prefs",
cmd_prefs, parse_args, 0, 1, NULL, cmd_prefs, parse_args, 0, 1, NULL,
@ -1081,7 +1160,8 @@ static struct cmd_t command_defs[] =
"presence : Chat presence preferences.", "presence : Chat presence preferences.",
"", "",
"No argument shows all preferences.", "No argument shows all preferences.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/theme", { "/theme",
cmd_theme, parse_args, 1, 2, &cons_theme_setting, cmd_theme, parse_args, 1, 2, &cons_theme_setting,
@ -1096,8 +1176,8 @@ static struct cmd_t command_defs[] =
"", "",
"Example: /theme list", "Example: /theme list",
"Example: /theme load mycooltheme", "Example: /theme load mycooltheme",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/statuses", { "/statuses",
cmd_statuses, parse_args, 2, 2, &cons_statuses_setting, cmd_statuses, parse_args, 2, 2, &cons_statuses_setting,
@ -1121,7 +1201,8 @@ static struct cmd_t command_defs[] =
"Example: /statuses console none", "Example: /statuses console none",
"Example: /statuses chat online", "Example: /statuses chat online",
"Example: /statuses muc all", "Example: /statuses muc all",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/xmlconsole", { "/xmlconsole",
cmd_xmlconsole, parse_args, 0, 0, NULL, cmd_xmlconsole, parse_args, 0, 0, NULL,
@ -1129,7 +1210,8 @@ static struct cmd_t command_defs[] =
{ "/xmlconsole", { "/xmlconsole",
"-----------", "-----------",
"Open the XML console to view incoming and outgoing XMPP traffic.", "Open the XML console to view incoming and outgoing XMPP traffic.",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/away", { "/away",
cmd_away, parse_args_with_freetext, 0, 1, NULL, cmd_away, parse_args_with_freetext, 0, 1, NULL,
@ -1139,7 +1221,8 @@ static struct cmd_t command_defs[] =
"Set your status to 'away' with the optional message.", "Set your status to 'away' with the optional message.",
"", "",
"Example: /away Gone for lunch", "Example: /away Gone for lunch",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/chat", { "/chat",
cmd_chat, parse_args_with_freetext, 0, 1, NULL, cmd_chat, parse_args_with_freetext, 0, 1, NULL,
@ -1149,7 +1232,8 @@ static struct cmd_t command_defs[] =
"Set your status to 'chat', meaning 'available for chat', with the optional message.", "Set your status to 'chat', meaning 'available for chat', with the optional message.",
"", "",
"Example: /chat Please talk to me!", "Example: /chat Please talk to me!",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/dnd", { "/dnd",
cmd_dnd, parse_args_with_freetext, 0, 1, NULL, cmd_dnd, parse_args_with_freetext, 0, 1, NULL,
@ -1159,7 +1243,8 @@ static struct cmd_t command_defs[] =
"Set your status to 'dnd', meaning 'do not disturb', with the optional message.", "Set your status to 'dnd', meaning 'do not disturb', with the optional message.",
"", "",
"Example: /dnd I'm in the zone", "Example: /dnd I'm in the zone",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/online", { "/online",
cmd_online, parse_args_with_freetext, 0, 1, NULL, cmd_online, parse_args_with_freetext, 0, 1, NULL,
@ -1169,7 +1254,8 @@ static struct cmd_t command_defs[] =
"Set your status to 'online' with the optional message.", "Set your status to 'online' with the optional message.",
"", "",
"Example: /online Up the Irons!", "Example: /online Up the Irons!",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
{ "/xa", { "/xa",
cmd_xa, parse_args_with_freetext, 0, 1, NULL, cmd_xa, parse_args_with_freetext, 0, 1, NULL,
@ -1179,7 +1265,8 @@ static struct cmd_t command_defs[] =
"Set your status to 'xa', meaning 'extended away', with the optional message.", "Set your status to 'xa', meaning 'extended away', with the optional message.",
"", "",
"Example: /xa This meeting is going to be a long one", "Example: /xa This meeting is going to be a long one",
NULL } } }, NULL,
NULL, NULL, NULL, NULL } } },
}; };
static Autocomplete commands_ac; static Autocomplete commands_ac;

View File

@ -852,21 +852,22 @@ cmd_help(ProfWin *window, gchar **args, struct cmd_help_t help)
char cmd_with_slash[1 + strlen(cmd) + 1]; char cmd_with_slash[1 + strlen(cmd) + 1];
sprintf(cmd_with_slash, "/%s", cmd); sprintf(cmd_with_slash, "/%s", cmd);
const gchar **help_text = NULL;
Command *command = g_hash_table_lookup(commands, cmd_with_slash); Command *command = g_hash_table_lookup(commands, cmd_with_slash);
if (command) { if (command) {
help_text = command->help.long_help; // old
} if (command->help.usage) {
const gchar **help_text = command->help.long_help;
ProfWin *console = wins_get_console();
cons_show("");
ui_show_lines(console, help_text);
cons_show(""); // new
if (help_text) { } else {
ProfWin *console = wins_get_console(); cons_show_help(command);
ui_show_lines(console, help_text); }
} else { } else {
cons_show("No such command."); cons_show("No such command.");
} }
cons_show(""); cons_show("");
} }

View File

@ -35,13 +35,18 @@
#ifndef COMMANDS_H #ifndef COMMANDS_H
#define COMMANDS_H #define COMMANDS_H
#include "ui/ui.h" #include "ui/win_types.h"
// Command help strings // Command help strings
typedef struct cmd_help_t { typedef struct cmd_help_t {
const gchar *usage; const gchar *usage;
const gchar *short_help; const gchar *short_help;
const gchar *long_help[50]; const gchar *long_help[50];
const gchar *synopsis[50];
const gchar *desc;
const gchar *args[50][2];
const gchar *examples[10];
} CommandHelp; } CommandHelp;
/* /*

View File

@ -105,6 +105,42 @@ cons_show(const char * const msg, ...)
va_end(arg); va_end(arg);
} }
void
cons_show_help(Command *command)
{
ProfWin *console = wins_get_console();
cons_show("");
cons_show("Synopsis:");
ui_show_lines(console, command->help.synopsis);
cons_show("");
cons_show("Description:");
win_println(console, command->help.desc);
int i;
int maxlen = 0;
for (i = 0; command->help.args[i][0] != NULL; i++) {
if (strlen(command->help.args[i][0]) > maxlen)
maxlen = strlen(command->help.args[i][0]);
}
if (i > 0) {
cons_show("");
cons_show("Arguments:");
for (i = 0; command->help.args[i][0] != NULL; i++) {
win_vprint(console, '-', NULL, 0, 0, "", "%-*s: %s", maxlen + 1, command->help.args[i][0], command->help.args[i][1]);
}
}
if (g_strv_length((gchar**)command->help.examples) > 0) {
cons_show("");
cons_show("Examples:");
ui_show_lines(console, command->help.examples);
}
}
void void
cons_show_error(const char * const msg, ...) cons_show_error(const char * const msg, ...)
{ {

View File

@ -35,6 +35,7 @@
#ifndef UI_UI_H #ifndef UI_UI_H
#define UI_UI_H #define UI_UI_H
#include "command/commands.h"
#include "ui/win_types.h" #include "ui/win_types.h"
#include "muc.h" #include "muc.h"
@ -241,6 +242,7 @@ void ui_inp_history_append(char *inp);
void cons_show(const char * const msg, ...); void cons_show(const char * const msg, ...);
void cons_about(void); void cons_about(void);
void cons_help(void); void cons_help(void);
void cons_show_help(Command *command);
void cons_navigation_help(void); void cons_navigation_help(void);
void cons_prefs(void); void cons_prefs(void);
void cons_show_ui_prefs(void); void cons_show_ui_prefs(void);

View File

@ -358,6 +358,8 @@ void cons_show(const char * const msg, ...)
va_end(args); va_end(args);
} }
void cons_show_help(Command *command) {}
void cons_about(void) {} void cons_about(void) {}
void cons_help(void) {} void cons_help(void) {}
void cons_navigation_help(void) {} void cons_navigation_help(void) {}