lttng: list valid condition / action names if missing or unknown
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 25 Aug 2021 18:39:11 +0000 (14:39 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 17 Dec 2021 05:31:09 +0000 (00:31 -0500)
commit074060e8e7d729d94e69ced71ed52b4a40c982c2
tree53e818a77566845d68290cdffed76653bddefaa5
parent9d28679a3d23e2404d42fd9f8abe0002797a6213
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 <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng/commands/add_trigger.c
src/bin/lttng/commands/list_triggers.c
src/bin/lttng/commands/remove_trigger.c
src/common/argpar-utils/argpar-utils.c
src/common/argpar-utils/argpar-utils.h
tests/regression/tools/trigger/test_add_trigger_cli
This page took 0.025235 seconds and 4 git commands to generate.