From: Simon Marchi Date: Wed, 25 Aug 2021 18:39:11 +0000 (-0400) Subject: lttng: list valid condition / action names if missing or unknown X-Git-Url: https://git.liburcu.org/?a=commitdiff_plain;h=ef9ff9cb5ff4dd763d4c9dbbcfcb5952adce167e;hp=ef9ff9cb5ff4dd763d4c9dbbcfcb5952adce167e;p=lttng-tools.git lttng: list valid condition / action names if missing or unknown I think it would be helpful to the user to list the condition and action names, when the condition or action name is missing or unrecognized. This patch implements that, here are some examples of the result: $ lttng add-trigger --action notify --condition Error: While parsing argument #4: Missing required argument for option `--condition` Error: Valid condition names are: Error: event-rule-matches $ lttng add-trigger --action notify --condition pouet Error: While parsing argument #5: Unknown condition name 'pouet' Error: Valid condition names are: Error: event-rule-matches $ lttng add-trigger --condition event-rule-matches --action Error: While parsing argument #4: Missing required argument for option `--action` Error: Valid action names are: Error: notify $ lttng add-trigger --condition event-rule-matches --action pouet Error: While parsing argument #5: Unknown action name: pouet Error: Valid action names are: Error: notify To achieve this, add a new optional out argument to parse_next_item, to allow the caller to get the argpar_error object if a parsing error happened. Because of this, the callers must now be able to differentiate parsing error from memory errors: in the latter case, no argpar_error object is returned. So, add a new PARSE_NEXT_ITEM_STATUS_ERROR_MEMORY status, and make users of parse_next_item handle it. In the add-trigger command implementation, handle the "missing opt arg" case of OPT_ACTION and OPT_CONDITION specially to print the valid names. Handle unknown names in parse_action and parse_condition. Add a test for an unknown action name, it seems to be missing. Change the error message format slightly to make it match the messages for unknown condition names. Change-Id: I4c13cecacb3a2ff4367e391c4aba0d05f1f28f22 Signed-off-by: Simon Marchi Signed-off-by: Jérémie Galarneau ---