# HG changeset patch # User Kim Alvefur # Date 1643997694 -3600 # Node ID 47d5233a1fc79d7484e3edab2af3953d6dc9bc65 # Parent ba712f7559dc6ba20b19c34fe4dc003e0d97882e prosodyctl: Return success status code from --help Only when the help is shown because of invalid arguments should a non-zero status code be returned to indicate a problem. diff -r ba712f7559dc -r 47d5233a1fc7 prosodyctl --- a/prosodyctl Fri Feb 04 18:56:01 2022 +0100 +++ b/prosodyctl Fri Feb 04 19:01:34 2022 +0100 @@ -80,7 +80,7 @@ local opts = parse_args(arg, only_help); if opts.help or not arg[1] then show_usage([[install]], [[Installs a prosody/luarocks plugin]]); - return 1; + return opts.help and 0 or 1; end -- TODO finalize config option name local server = configmanager.get("*", "plugin_server"); @@ -102,7 +102,7 @@ local opts = parse_args(arg, only_help); if opts.help or not arg[1] then show_usage([[remove]], [[Removes a module installed in the working directory's plugins folder]]); - return 1; + return opts.help and 0 or 1; end show_message("Removing %s from %s", arg[1], prosody.paths.installer); local ret = call_luarocks("remove", arg[1]); @@ -113,7 +113,7 @@ local opts = parse_args(arg, only_help); if opts.help then show_usage([[list]], [[Shows installed rocks]]); - return 1; + return 0; end local ret = call_luarocks("list", arg[1]); return ret; @@ -123,7 +123,7 @@ local opts = parse_args(arg, only_help); if opts.help or not arg[1] then show_usage([[adduser JID]], [[Create the specified user account in Prosody]]); - return 1; + return opts.help and 0 or 1; end local user, host = jid_split(arg[1]); if not user and host then @@ -163,7 +163,7 @@ local opts = parse_args(arg, only_help); if opts.help or not arg[1] then show_usage([[passwd JID]], [[Set the password for the specified user account in Prosody]]); - return 1; + return opts.help and 0 or 1; end local user, host = jid_split(arg[1]); if not user and host then @@ -203,7 +203,7 @@ local opts = parse_args(arg, only_help); if opts.help or not arg[1] then show_usage([[deluser JID]], [[Permanently remove the specified user account from Prosody]]); - return 1; + return opts.help and 0 or 1; end local user, host = jid_split(arg[1]); if not user and host then @@ -262,7 +262,7 @@ local opts = parse_args(arg, only_help); if opts.help then show_usage([[start]], [[Start Prosody]]); - return 1; + return 0; end service_command_warning("start"); local ok, ret = prosodyctl.isrunning(); @@ -327,7 +327,7 @@ local opts = parse_args(arg, only_help); if opts.help then show_usage([[status]], [[Reports the running status of Prosody]]); - return 1; + return 0; end local ok, ret = prosodyctl.isrunning(); @@ -362,7 +362,7 @@ local opts = parse_args(arg, only_help); if opts.help then show_usage([[stop]], [[Stop a running Prosody server]]); - return 1; + return 0; end service_command_warning("stop"); @@ -413,7 +413,7 @@ local opts = parse_args(arg, only_help); if opts.help then show_usage([[about]], [[Show information about this Prosody installation]]); - return 1; + return 0; end local pwd = "."; @@ -535,7 +535,7 @@ local opts = parse_args(arg, only_help); if opts.help then show_usage([[reload]], [[Reload Prosody's configuration and re-open log files]]); - return 1; + return 0; end service_command_warning("reload");