]> git.saurik.com Git - redis.git/blame_incremental - deps/linenoise/example.c
32 bit build fixed on Linux.
[redis.git] / deps / linenoise / example.c
... / ...
CommitLineData
1#include <stdio.h>
2#include <stdlib.h>
3#include "linenoise.h"
4
5
6void completion(const char *buf, linenoiseCompletions *lc) {
7 if (buf[0] == 'h') {
8 linenoiseAddCompletion(lc,"hello");
9 linenoiseAddCompletion(lc,"hello there");
10 }
11}
12
13int main(void) {
14 char *line;
15
16 linenoiseSetCompletionCallback(completion);
17 linenoiseHistoryLoad("history.txt"); /* Load the history at startup */
18 while((line = linenoise("hello> ")) != NULL) {
19 if (line[0] != '\0') {
20 printf("echo: '%s'\n", line);
21 linenoiseHistoryAdd(line);
22 linenoiseHistorySave("history.txt"); /* Save every new entry */
23 }
24 free(line);
25 }
26 return 0;
27}