Software /
code /
prosody
Comparison
util/prosodyctl/shell.lua @ 10877:2b015ef8cd06
util.prosodyctl.shell: Save readline history
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 02 Jun 2020 09:35:07 +0200 |
parent | 10875:09674bbb833f |
child | 10937:d86f59c31458 |
comparison
equal
deleted
inserted
replaced
10876:c01c39a2c7a2 | 10877:2b015ef8cd06 |
---|---|
8 | 8 |
9 local adminstream = require "util.adminstream"; | 9 local adminstream = require "util.adminstream"; |
10 | 10 |
11 if have_readline then | 11 if have_readline then |
12 readline.set_readline_name("prosody"); | 12 readline.set_readline_name("prosody"); |
13 readline.set_options({ | |
14 histfile = path.join(prosody.paths.data, ".shell_history"); | |
15 ignoredups = true; | |
16 }); | |
13 end | 17 end |
14 | 18 |
15 local function read_line() | 19 local function read_line() |
16 if have_readline then | 20 if have_readline then |
17 return readline.readline("prosody> "); | 21 return readline.readline("prosody> "); |
28 local function repl(client) | 32 local function repl(client) |
29 local line = read_line(); | 33 local line = read_line(); |
30 if not line or line == "quit" or line == "exit" or line == "bye" then | 34 if not line or line == "quit" or line == "exit" or line == "bye" then |
31 if not line then | 35 if not line then |
32 print(""); | 36 print(""); |
37 end | |
38 if have_readline then | |
39 readline.save_history(); | |
33 end | 40 end |
34 os.exit(); | 41 os.exit(); |
35 end | 42 end |
36 send_line(client, line); | 43 send_line(client, line); |
37 end | 44 end |