Mercurial > prosody-hg
comparison util/prosodyctl/shell.lua @ 10874:98c535531450
util.prosodyctl.shell: Really fix --socket option
Forgot it stops parsing --foo options at the first argument, so
subsequent commands need to parse their own options like this.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Tue, 02 Jun 2020 09:19:07 +0200 |
| parents | 813e632431e6 |
| children | 09674bbb833f |
comparison
equal
deleted
inserted
replaced
| 10873:813e632431e6 | 10874:98c535531450 |
|---|---|
| 8 | 8 |
| 9 local config = require "core.configmanager"; | 9 local config = require "core.configmanager"; |
| 10 local server = require "net.server"; | 10 local server = require "net.server"; |
| 11 local st = require "util.stanza"; | 11 local st = require "util.stanza"; |
| 12 local path = require "util.paths"; | 12 local path = require "util.paths"; |
| 13 local parse_args = require "util.argparse".parse; | |
| 13 | 14 |
| 14 local have_readline, readline = pcall(require, "readline"); | 15 local have_readline, readline = pcall(require, "readline"); |
| 15 | 16 |
| 16 local adminstream = require "util.adminstream"; | 17 local adminstream = require "util.adminstream"; |
| 17 | 18 |
| 89 print("https://prosody.im/doc/console\n"); | 90 print("https://prosody.im/doc/console\n"); |
| 90 end | 91 end |
| 91 | 92 |
| 92 local function start(arg) --luacheck: ignore 212/arg | 93 local function start(arg) --luacheck: ignore 212/arg |
| 93 local client = adminstream.client(); | 94 local client = adminstream.client(); |
| 95 local opts = parse_args(arg); | |
| 94 | 96 |
| 95 client.events.add_handler("connected", function () | 97 client.events.add_handler("connected", function () |
| 96 if not arg.quiet then | 98 if not arg.quiet then |
| 97 printbanner(); | 99 printbanner(); |
| 98 end | 100 end |
| 112 if stanza.name == "repl-result" then | 114 if stanza.name == "repl-result" then |
| 113 repl(client); | 115 repl(client); |
| 114 end | 116 end |
| 115 end); | 117 end); |
| 116 | 118 |
| 117 local socket_path = path.resolve_relative_path(prosody.paths.data, prosody.opts.socket or config.get("*", "admin_socket") or "prosody.sock"); | 119 local socket_path = path.resolve_relative_path(prosody.paths.data, opts.socket or config.get("*", "admin_socket") or "prosody.sock"); |
| 118 local conn = connection(socket_path, client.listeners); | 120 local conn = connection(socket_path, client.listeners); |
| 119 local ok, err = conn:connect(); | 121 local ok, err = conn:connect(); |
| 120 if not ok then | 122 if not ok then |
| 121 print("** Unable to connect to server - is it running? Is mod_admin_shell enabled?"); | 123 print("** Unable to connect to server - is it running? Is mod_admin_shell enabled?"); |
| 122 print("** Connection error: "..err); | 124 print("** Connection error: "..err); |
