MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / repl

Function repl

src/redis-cli.c:1964–2101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1962}
1963
1964static void repl(void) {
1965 sds historyfile = NULL;
1966 int history = 0;
1967 char *line;
1968 int argc;
1969 sds *argv;
1970
1971 /* Initialize the help and, if possible, use the COMMAND command in order
1972 * to retrieve missing entries. */
1973 cliInitHelp();
1974 cliIntegrateHelp();
1975
1976 config.interactive = 1;
1977 linenoiseSetMultiLine(1);
1978 linenoiseSetCompletionCallback(completionCallback);
1979 linenoiseSetHintsCallback(hintsCallback);
1980 linenoiseSetFreeHintsCallback(freeHintsCallback);
1981
1982 /* Only use history and load the rc file when stdin is a tty. */
1983 if (isatty(fileno(stdin))) {
1984 historyfile = getDotfilePath(REDIS_CLI_HISTFILE_ENV,REDIS_CLI_HISTFILE_DEFAULT);
1985 //keep in-memory history always regardless if history file can be determined
1986 history = 1;
1987 if (historyfile != NULL) {
1988 linenoiseHistoryLoad(historyfile);
1989 }
1990 cliLoadPreferences();
1991 }
1992
1993 cliRefreshPrompt();
1994 while((line = linenoise(context ? config.prompt : "not connected> ")) != NULL) {
1995 if (line[0] != '\0') {
1996 long repeat = 1;
1997 int skipargs = 0;
1998 char *endptr = NULL;
1999
2000 argv = cliSplitArgs(line,&argc);
2001
2002 /* check if we have a repeat command option and
2003 * need to skip the first arg */
2004 if (argv && argc > 0) {
2005 errno = 0;
2006 repeat = strtol(argv[0], &endptr, 10);
2007 if (argc > 1 && *endptr == '\0') {
2008 if (errno == ERANGE || errno == EINVAL || repeat <= 0) {
2009 fputs("Invalid keydb-cli repeat command option value.\n", stdout);
2010 sdsfreesplitres(argv, argc);
2011 linenoiseFree(line);
2012 continue;
2013 }
2014 skipargs = 1;
2015 } else {
2016 repeat = 1;
2017 }
2018 }
2019
2020 /* Won't save auth or acl setuser commands in history file */
2021 int dangerous = 0;

Callers 2

evalModeFunction · 0.85
mainFunction · 0.85

Calls 15

cliInitHelpFunction · 0.85
cliIntegrateHelpFunction · 0.85
linenoiseSetMultiLineFunction · 0.85
getDotfilePathFunction · 0.85
linenoiseHistoryLoadFunction · 0.85
cliLoadPreferencesFunction · 0.85
cliRefreshPromptFunction · 0.85
linenoiseFunction · 0.85
cliSplitArgsFunction · 0.85

Tested by

no test coverage detected