| 298 | } |
| 299 | |
| 300 | static void cliRefreshPrompt(void) { |
| 301 | if (config.eval_ldb) return; |
| 302 | |
| 303 | sds prompt = sdsempty(); |
| 304 | if (config.hostsocket != NULL) { |
| 305 | prompt = sdscatfmt(prompt,"redis %s",config.hostsocket); |
| 306 | } else { |
| 307 | char addr[256]; |
| 308 | anetFormatAddr(addr, sizeof(addr), config.hostip, config.hostport); |
| 309 | prompt = sdscatlen(prompt,addr,strlen(addr)); |
| 310 | } |
| 311 | |
| 312 | /* Add [dbnum] if needed */ |
| 313 | if (config.dbnum != 0) |
| 314 | prompt = sdscatfmt(prompt,"[%i]",config.dbnum); |
| 315 | |
| 316 | /* Add TX if in transaction state*/ |
| 317 | if (config.in_multi) |
| 318 | prompt = sdscatlen(prompt,"(TX)",4); |
| 319 | |
| 320 | /* Copy the prompt in the static buffer. */ |
| 321 | prompt = sdscatlen(prompt,"> ",2); |
| 322 | snprintf(config.prompt,sizeof(config.prompt),"%s",prompt); |
| 323 | sdsfree(prompt); |
| 324 | } |
| 325 | |
| 326 | /* Return the name of the dotfile for the specified 'dotfilename'. |
| 327 | * Normally it just concatenates user $HOME to the file specified |
no test coverage detected