From cf122397733b8795530577b7824aeae305719658 Mon Sep 17 00:00:00 2001 From: Huanxuan Ao Date: Tue, 7 Jun 2016 16:41:21 +0800 Subject: Error handling for KeyValueAction class. The set --property command requires that the input match the "key=value" type, but if the type don't match, the return value will be None, and the command still can be implemented successfully, this may confuse the users. I think we should raise exception if the argument type don't match "key=value". So I make some changes in KeyValueAction class in this patch. Change-Id: I14e64922faa7e083bc8b5e7e1cac41ef8117c224 Closes-Bug: #1589935 --- openstackclient/common/parseractions.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'openstackclient/common') diff --git a/openstackclient/common/parseractions.py b/openstackclient/common/parseractions.py index 77798f90..8f772344 100644 --- a/openstackclient/common/parseractions.py +++ b/openstackclient/common/parseractions.py @@ -35,7 +35,9 @@ class KeyValueAction(argparse.Action): if '=' in values: getattr(namespace, self.dest, {}).update([values.split('=', 1)]) else: - getattr(namespace, self.dest, {}).pop(values, None) + msg = _("Expected 'key=value' type, " + "but got: %s") % (str(values)) + raise argparse.ArgumentTypeError(msg) class MultiKeyValueAction(argparse.Action): -- cgit v1.2.1