options (currently '%s')\n", ps->opt.tableOpt? ps->opt.tableOpt: "");
fprintf(stderr,"\t \\x -- toggle expanded output (currently %s)\n", on(ps->opt.expanded));
- fprintf(stderr,"\t \\z -- zorch current query buffer (i.e clear it)\n");
fprintf(stderr,"\t \\! [] -- shell escape or command\n");
- fprintf(stderr,"\t \\? -- help\n");
}
PGresult *
decode(optarg);
}
switch (line[1])
- {
+ {
case 'a': /* toggles to align fields on output */
toggle(settings, &settings->opt.align, "field alignment");
break;
}
break;
case 'c': /* \c means connect to new database */
- {
+ {
char *dbname=PQdb(settings->db);
if (!optarg) {
fprintf(stderr,"\\c must be followed by a database name\n");
}
break;
case 'e':
- {
+ {
int fd;
char tmp[64];
char *fname;
if (query[strlen(query)-1]==';')
return 0;
break;
- }
+ }
+ case 'E':
+ {
+ FILE *fd;
+ static char *lastfile;
+ struct stat st, st2;
+ if (optarg)
+ {
+ if (lastfile)
+ free(lastfile);
+ lastfile=malloc(strlen(optarg+1));
+ if (!lastfile)
+ {
+ perror("malloc");
+ exit(1);
+ }
+ strcpy(lastfile, optarg);
+ } else if (!lastfile)
+ {
+ fprintf(stderr,"\\r must be followed by a file name initially\n");
+ break;
+ }
+ stat(lastfile, &st);
+ editFile(lastfile);
+ if ((stat(lastfile, &st2) == -1) || ((fd = fopen(lastfile, "r")) == NULL))
+ {
+ perror(lastfile);
+ break;
+ }
+ if (st2.st_mtime==st.st_mtime)
+ {
+ if (!settings->quiet)
+ fprintf(stderr, "warning: %s not modified. query not executed\n", lastfile);
+ fclose(fd);
+ break;
+ }
+ MainLoop(settings, fd);
+ fclose(fd);
+ break;
+ }
case 'f':
{
char *fs=DEFAULT_FIELD_SEP;
fprintf(stderr, "field separater changed to '%s'\n", settings->opt.fieldSep);
break;
}
- case 'g': /* \g means send query */
+ case 'g': /* \g means send query */
settings->gfname = optarg;
status = 0;
break;
case 'h':
- {
+ {
char *cmd;
int i, numCmds;
int all_help = 0;
printf("command not found, try \\h with no arguments to see available help\n");
}
break;
- }
+ }
case 'i': /* \i is include file */
{
FILE *fd;
MainLoop(settings, fd);
fclose(fd);
break;
- }
+ }
case 'l': /* \l is list database */
listAllDbs(settings);
break;
case 'q': /* \q is quit */
status = 2;
break;
- case 'r':
- {
- FILE *fd;
- static char *lastfile;
- struct stat st, st2;
- if (optarg)
- {
- if (lastfile)
- free(lastfile);
- lastfile=malloc(strlen(optarg+1));
- if (!lastfile)
- {
- perror("malloc");
- exit(1);
- }
- strcpy(lastfile, optarg);
- } else if (!lastfile)
- {
- fprintf(stderr,"\\r must be followed by a file name initially\n");
- break;
- }
- stat(lastfile, &st);
- editFile(lastfile);
- if ((stat(lastfile, &st2) == -1) || ((fd = fopen(lastfile, "r")) == NULL))
- {
- perror(lastfile);
- break;
- }
- if (st2.st_mtime==st.st_mtime)
- {
- if (!settings->quiet)
- fprintf(stderr, "warning: %s not modified. query not executed\n", lastfile);
- fclose(fd);
- break;
- }
- MainLoop(settings, fd);
- fclose(fd);
- break;
- }
+ case 'r': /* reset(clear) the buffer */
+ query[0]='\0';
+ if (!settings->quiet)
+ fprintf(stderr, "buffer reset(cleared)\n");
+ break;
case 's': /* \s is save history to a file */
if (!optarg)
optarg="/dev/tty";
}
break;
case 't': /* toggle headers */
- toggle(settings, &settings->opt.header, "output headers");
+ toggle(settings, &settings->opt.header, "output headings and row count");
break;
case 'T': /* define html
option */
if (settings->opt.tableOpt)
case 'x':
toggle(settings, &settings->opt.expanded, "expanded table representation");
break;
- case 'z': /* zorch buffer */
- query[0]='\0';
- if (!settings->quiet)
- fprintf(stderr, "zorched current query buffer\n");
- break;
case '!':
if (!optarg) {
char *sys;