Diff

util/prosodyctl/shell.lua @ 11890:b9aab1962a2b

util.prosodyctl.shell: Allow setting custom prompt (admin_shell_prompt)
author Matthew Wild <mwild1@gmail.com>
date Thu, 11 Nov 2021 13:27:28 +0000
parent 11522:5bd38d9197e1
child 11902:98fd531594bd
line wrap: on
line diff
--- a/util/prosodyctl/shell.lua	Wed Nov 10 21:31:41 2021 +0100
+++ b/util/prosodyctl/shell.lua	Thu Nov 11 13:27:28 2021 +0000
@@ -17,11 +17,11 @@
 		});
 end
 
-local function read_line()
+local function read_line(prompt_string)
 	if have_readline then
-		return readline.readline("prosody> ");
+		return readline.readline(prompt_string);
 	else
-		io.write("prosody> ");
+		io.write(prompt_string);
 		return io.read("*line");
 	end
 end
@@ -31,7 +31,7 @@
 end
 
 local function repl(client)
-	local line = read_line();
+	local line = read_line(client.prompt_string or "prosody> ");
 	if not line or line == "quit" or line == "exit" or line == "bye" then
 		if not line then
 			print("");
@@ -123,6 +123,8 @@
 		end
 	end);
 
+	client.prompt_string = config.get("*", "admin_shell_prompt");
+
 	local socket_path = path.resolve_relative_path(prosody.paths.data, opts.socket or config.get("*", "admin_socket") or "prosody.sock");
 	local conn = adminstream.connection(socket_path, client.listeners);
 	local ok, err = conn:connect();