Changeset

13412:0e96d6a29a12

mod_invites: Show short help instead of traceback on missing hostname
author Kim Alvefur <zash@zash.se>
date Sat, 13 Jan 2024 11:00:20 +0100
parents 13411:d815882d2692
children 13413:992389af2372
files plugins/mod_invites.lua
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_invites.lua	Sat Jan 13 10:59:04 2024 +0100
+++ b/plugins/mod_invites.lua	Sat Jan 13 11:00:20 2024 +0100
@@ -249,9 +249,10 @@
 end
 
 function subcommands.generate(arg)
-	local function help()
+	local function help(short)
 		print("usage: prosodyctl mod_" .. module.name .. " generate DOMAIN --reset USERNAME")
 		print("usage: prosodyctl mod_" .. module.name .. " generate DOMAIN [--admin] [--role ROLE] [--group GROUPID]...")
+		if short then return 2 end
 		print()
 		print("This command has two modes: password reset and new account.")
 		print("If --reset is given, the command operates in password reset mode and in new account mode otherwise.")
@@ -284,7 +285,7 @@
 	local mm = require "prosody.core.modulemanager";
 
 	local host = table.remove(arg, 1); -- pop host
-	assert(prosody.hosts[host], "Host "..tostring(host).." does not exist");
+	if not host then return help(true) end
 	sm.initialize_host(host);
 	module.host = host; --luacheck: ignore 122/module
 	token_storage = module:open_store("invite_token", "map");