Diff

util/prosodyctl/shell.lua @ 13046:4c3dc767fb11

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.
author Kim Alvefur <zash@zash.se>
date Fri, 07 Apr 2023 13:38:59 +0200
parent 12975:d10957394a3c
child 13047:d939bf469057
line wrap: on
line diff
--- 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)