summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a62e2e4)
raw | patch | inline | side by side (parent: a62e2e4)
author | Sebastian Harl <sh@tokkee.org> | |
Sun, 15 Dec 2013 08:49:10 +0000 (09:49 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sun, 15 Dec 2013 08:49:10 +0000 (09:49 +0100) |
Use a different prompt (similar to psql) when inside a query.
src/client/sysdb.c | patch | blob | history |
diff --git a/src/client/sysdb.c b/src/client/sysdb.c
index ada0ec3ae30f5dba633265eee73a2db937118a3c..ecadb4c18462cd94e61cfe116561269efe7622c0 100644 (file)
--- a/src/client/sysdb.c
+++ b/src/client/sysdb.c
const char *homedir;
char hist_file[1024] = "";
+ sdb_strbuf_t *buf;
+
while (42) {
int opt = getopt(argc, argv, "H:U:hV");
}
}
+ buf = sdb_strbuf_create(1024);
+
while (42) {
- char *line = readline("sysdb> ");
+ const char *prompt = "sysdb=> ";
+ const char *query;
+ char *input;
+
+ if (sdb_strbuf_len(buf))
+ prompt = "sysdb-> ";
+
+ input = readline(prompt);
- if (! line)
+ if (! input)
break;
- if (*line == '\0') {
- free(line);
- continue;
- }
- if (*line != ' ')
- add_history(line);
+ sdb_strbuf_append(buf, input);
+ free(input);
+
+ query = sdb_strbuf_string(buf);
+ if (! strchr(query, (int)';'))
+ continue;
- free(line);
+ /* XXX */
+ sdb_strbuf_clear(buf);
}
if (hist_file[0] != '\0') {