276
276
static COMMANDS commands[] = {
277
{ "?", '?', com_help, 1, N_("Synonym for `help'.") },
277
{ "?", '?', com_help, 0, N_("Synonym for `help'.") },
278
278
{ "clear", 'c', com_clear, 0, N_("Clear command.")},
279
279
{ "connect",'r', com_connect,1,
280
280
N_("Reconnect to the server. Optional arguments are db and host." }),
284
284
N_("Send command to drizzle server, display result vertically.")},
285
285
{ "exit", 'q', com_quit, 0, N_("Exit drizzle. Same as quit.")},
286
286
{ "go", 'g', com_go, 0, N_("Send command to drizzle server.") },
287
{ "help", 'h', com_help, 1, N_("Display this help.") },
287
{ "help", 'h', com_help, 0, N_("Display this help.") },
288
288
{ "nopager",'n', com_nopager,0, N_("Disable pager, print to stdout.") },
289
289
{ "notee", 't', com_notee, 0, N_("Don't write into outfile.") },
290
290
{ "pager", 'P', com_pager, 1,
2551
static void print_help_item(DRIZZLE_ROW *cur, int num_name, int num_cat, char *last_char)
2553
char ccat= (*cur)[num_cat][0];
2554
if (*last_char != ccat)
2556
put_info(ccat == 'Y' ? _("categories:") : _("topics:"), INFO_INFO,0,0);
2559
tee_fprintf(PAGER, " %s\n", (*cur)[num_name]);
2563
static int com_server_help(string *buffer, const char *, const char *help_arg)
2566
const char *server_cmd= buffer->c_str();
2568
DRIZZLE_RES *result;
2571
cmd_buf.reserve(100);
2572
if (help_arg[0] != '\'')
2574
const char *end_arg= strchr(help_arg, '\0');
2577
while (my_isspace(charset_info,*end_arg))
2580
cmd_buf.append("help '");
2581
cmd_buf.append(help_arg, end_arg-help_arg);
2582
cmd_buf.append("'");
2584
server_cmd= cmd_buf.c_str();
2587
if (!connected && reconnect())
2590
if ((error= drizzle_real_query_for_lazy(server_cmd,(int)strlen(server_cmd))) ||
2591
(error= drizzle_store_result_for_lazy(&result)))
2596
unsigned int num_fields= drizzle_num_fields(result);
2597
uint64_t num_rows= drizzle_num_rows(result);
2598
drizzle_fetch_fields(result);
2599
if (num_fields==3 && num_rows==1)
2601
if (!(cur= drizzle_fetch_row(result)))
2608
tee_fprintf(PAGER, _("Name: \'%s\'\n"), cur[0]);
2609
tee_fprintf(PAGER, _("Description:\n%s"), cur[1]);
2610
if (cur[2] && *((char*)cur[2]))
2611
tee_fprintf(PAGER, _("Examples:\n%s"), cur[2]);
2612
tee_fprintf(PAGER, "\n");
2615
else if (num_fields >= 2 && num_rows)
2620
int num_name= 0, num_cat= 0;
2622
if (num_fields == 2)
2624
put_info(_("Many help items for your request exist."), INFO_INFO,0,0);
2625
put_info(_("To make a more specific request, please type 'help <item>',\nwhere <item> is one of the following"), INFO_INFO,0,0);
2629
else if ((cur= drizzle_fetch_row(result)))
2631
tee_fprintf(PAGER, _("You asked for help about help category: '%s'\n"), cur[0]);
2632
put_info(_("For more information, type 'help <item>', where <item> is one of the following"), INFO_INFO,0,0);
2635
print_help_item(&cur,1,2,&last_char);
2638
while ((cur= drizzle_fetch_row(result)))
2639
print_help_item(&cur,num_name,num_cat,&last_char);
2640
tee_fprintf(PAGER, "\n");
2645
put_info(_("\nNothing found"), INFO_INFO,0,0);
2646
put_info(_("Please try to run 'help contents' for a list of all accessible topics\n"), INFO_INFO,0,0);
2651
drizzle_free_result(result);
2656
com_help(string *buffer, const char *line)
2552
com_help(string *buffer, const char *)
2658
2554
register int i, j;
2659
const char *help_arg= strchr(line,' ');
2660
2555
char buff[32], *end;
2663
while (my_isspace(charset_info,*help_arg))
2665
if (*help_arg) return com_server_help(buffer,line,help_arg);
2668
2557
put_info(_("List of all Drizzle commands:"), INFO_INFO,0,0);
2669
2558
if (!named_cmds)