Mercurial > prosody-hg
comparison 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 |
| parents | d10957394a3c |
| children | d939bf469057 |
comparison
equal
deleted
inserted
replaced
| 13045:da0b3cb9a2ec | 13046:4c3dc767fb11 |
|---|---|
| 4 local path = require "prosody.util.paths"; | 4 local path = require "prosody.util.paths"; |
| 5 local parse_args = require "prosody.util.argparse".parse; | 5 local parse_args = require "prosody.util.argparse".parse; |
| 6 local unpack = table.unpack or _G.unpack; | 6 local unpack = table.unpack or _G.unpack; |
| 7 local tc = require "prosody.util.termcolours"; | 7 local tc = require "prosody.util.termcolours"; |
| 8 local isatty = require "prosody.util.pposix".isatty; | 8 local isatty = require "prosody.util.pposix".isatty; |
| 9 local term_width = require"prosody.util.human.io".term_width; | |
| 9 | 10 |
| 10 local have_readline, readline = pcall(require, "readline"); | 11 local have_readline, readline = pcall(require, "readline"); |
| 11 | 12 |
| 12 local adminstream = require "prosody.util.adminstream"; | 13 local adminstream = require "prosody.util.adminstream"; |
| 13 | 14 |
| 27 return io.read("*line"); | 28 return io.read("*line"); |
| 28 end | 29 end |
| 29 end | 30 end |
| 30 | 31 |
| 31 local function send_line(client, line) | 32 local function send_line(client, line) |
| 32 client.send(st.stanza("repl-input", { width = os.getenv "COLUMNS" }):text(line)); | 33 client.send(st.stanza("repl-input", { width = os.getenv "COLUMNS" or term_width() }):text(line)); |
| 33 end | 34 end |
| 34 | 35 |
| 35 local function repl(client) | 36 local function repl(client) |
| 36 local line = read_line(client.prompt_string or "prosody> "); | 37 local line = read_line(client.prompt_string or "prosody> "); |
| 37 if not line or line == "quit" or line == "exit" or line == "bye" then | 38 if not line or line == "quit" or line == "exit" or line == "bye" then |
