From a4a28c779e04b0976f26c5c72c2aa0310aea8c67 Mon Sep 17 00:00:00 2001 From: jesopo Date: Thu, 27 Feb 2020 18:03:21 +0000 Subject: show usage strings when spec parsing fails --- src/core_modules/command_spec/__init__.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/core_modules/command_spec') diff --git a/src/core_modules/command_spec/__init__.py b/src/core_modules/command_spec/__init__.py index 196afbd6..1fdd02a9 100644 --- a/src/core_modules/command_spec/__init__.py +++ b/src/core_modules/command_spec/__init__.py @@ -133,4 +133,16 @@ class Module(ModuleManager.BaseModule): if count >= best_count: overall_error = current_error - return utils.consts.PERMISSION_HARD_FAIL, overall_error + error_out = overall_error + + if event["is_channel"]: + context = utils.parse.SpecArgumentContext.CHANNEL + else: + context = utils.parse.SpecArgumentContext.PRIVATE + usages = " | ".join( + [utils.parse.argument_spec_human(s, context) for s in specs]) + + command = "%s%s" % (event["command_prefix"], event["command"]) + error_out = "%s (Usage: %s)" % (overall_error, usages) + + return utils.consts.PERMISSION_HARD_FAIL, error_out -- cgit v1.3.1-10-gc9f91