util.prosodyctl.shell: Use new term_width() for width
authorKim Alvefur <zash@zash.se>
Fri, 07 Apr 2023 13:38:59 +0200
changeset 13050 4c3dc767fb11
parent 13049 da0b3cb9a2ec
child 13051 d939bf469057
util.prosodyctl.shell: Use new term_width() for width Kicks in if/when readline hasn't set $COLUMNS, e.g. when using the `prosodyctl shell command like this` form.
util/prosodyctl/shell.lua
--- a/util/prosodyctl/shell.lua	Fri Apr 07 12:35:39 2023 +0100
+++ b/util/prosodyctl/shell.lua	Fri Apr 07 13:38:59 2023 +0200
@@ -6,6 +6,7 @@
 local unpack = table.unpack or _G.unpack;
 local tc = require "prosody.util.termcolours";
 local isatty = require "prosody.util.pposix".isatty;
+local term_width = require"prosody.util.human.io".term_width;
 
 local have_readline, readline = pcall(require, "readline");
 
@@ -29,7 +30,7 @@
 end
 
 local function send_line(client, line)
-	client.send(st.stanza("repl-input", { width = os.getenv "COLUMNS" }):text(line));
+	client.send(st.stanza("repl-input", { width = os.getenv "COLUMNS" or term_width() }):text(line));
 end
 
 local function repl(client)