Software /
code /
prosody
Comparison
util/prosodyctl/check.lua @ 12376:10353ad0ca7a
prosodyctl: check: Slightly improved argument handling
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 05 Mar 2022 11:36:38 +0000 |
parent | 12375:ea5e46601cfb |
child | 12377:317132bca8c0 |
comparison
equal
deleted
inserted
replaced
12375:ea5e46601cfb | 12376:10353ad0ca7a |
---|---|
252 | 252 |
253 local check_opts = { | 253 local check_opts = { |
254 short_params = { | 254 short_params = { |
255 h = "help", v = "verbose"; | 255 h = "help", v = "verbose"; |
256 }; | 256 }; |
257 value_params = { | |
258 ping = true; | |
259 }; | |
257 }; | 260 }; |
258 | 261 |
259 local function check(arg) | 262 local function check(arg) |
260 if arg[1] == "help" or arg[1] == "--help" then | 263 if arg[1] == "help" or arg[1] == "--help" then |
261 show_usage([[check]], [[Perform basic checks on your Prosody installation]]); | 264 show_usage([[check]], [[Perform basic checks on your Prosody installation]]); |
262 return 1; | 265 return 1; |
263 end | 266 end |
264 local what = table.remove(arg, 1); | 267 local what = table.remove(arg, 1); |
265 local opts = assert(parse_args(arg, check_opts)); | 268 local opts, opts_err, opts_info = parse_args(arg, check_opts); |
269 if opts_err == "missing-value" then | |
270 print("Error: Expected a value after '"..opts_info.."'"); | |
271 return 1; | |
272 elseif opts_err == "param-not-found" then | |
273 print("Error: Unknown parameter: "..opts_info); | |
274 return 1; | |
275 end | |
266 local array = require "util.array"; | 276 local array = require "util.array"; |
267 local set = require "util.set"; | 277 local set = require "util.set"; |
268 local it = require "util.iterators"; | 278 local it = require "util.iterators"; |
269 local ok = true; | 279 local ok = true; |
270 local function disabled_hosts(host, conf) return host ~= "*" and conf.enabled ~= false; end | 280 local function disabled_hosts(host, conf) return host ~= "*" and conf.enabled ~= false; end |