Skip to content

Commit 29f7850

Browse files
committed
Redefine set/unset command devref
Now we have some use cases about set/unset properties, try to redefine devref to find out a best and easiest solution to keep commands simple and clearly. Five use cases exist in property action, "append", "update", "remove", "clean", "override", the following rules can cover all these use cases: 1. append ==> "set --property new-key=value" 2. update ==> "set --property existed-key=new-value" 3. remove ==> "unset --property existed-key" 4. clean ==> "set --no-property" 5. clean ==> "unset --all-property" 6. override ==> "set --no-property --property new-key=value" Related blueprint support-no-property-in-aggregate and blueprint allow-overwrite-set-options. Change-Id: If86daf6989d8e0ad0dc6e590d7636be7d5203a18
1 parent 762f2f2 commit 29f7850

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

doc/source/command-options.rst

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ Some options can be repeated to build a collection of values for a property.
118118
Adding a value to the collection must be provided via the ``set`` action.
119119
Removing a value from the collection must be provided via an ``unset`` action.
120120
As a convenience, removing all values from the collection may be provided via a
121-
``--no`` option on the ``set`` and ``unset`` actions. If both ``--no`` option
122-
and option are specified, the values specified on the command would overwrite
123-
the collection property instead of appending on the ``set`` action. The
124-
``--no`` option must be part of a mutually exclusive group with the related
125-
property option on the ``unset`` action, overwrite case don't exist in
126-
``unset`` action.
121+
``--no`` option on the ``set`` action and a ``--all`` option on ``unset``
122+
action. If both ``--no`` option and option are specified, the values specified
123+
on the command would overwrite the collection property instead of appending on
124+
the ``set`` action. The ``--all`` option must be part of a mutually exclusive
125+
group with the related property option on the ``unset`` action, overwrite case
126+
don't exist in ``unset`` action.
127127

128128
An example behavior for ``set`` action:
129129

@@ -165,7 +165,9 @@ An example parser declaration for `set` action:
165165
'--no-example-property',
166166
dest='no_example_property',
167167
action='store_true',
168-
help=_('Remove all example properties for this <resource>'),
168+
help=_('Remove all example properties for this <resource> '
169+
'(specify both --example-property and --no-example-property'
170+
' to overwrite the current example properties)'),
169171
)
170172
171173
An example handler in `take_action()` for `set` action:
@@ -194,8 +196,8 @@ An example parser declaration for `unset` action:
194196
'(repeat option to remove multiple properties)'),
195197
)
196198
example_property_group.add_argument(
197-
'--no-example-property',
198-
dest='no_example_property',
199+
'--all-example-property',
200+
dest='all_example_property',
199201
action='store_true',
200202
help=_('Remove all example properties for this <resource>'),
201203
)
@@ -208,7 +210,7 @@ An example handler in `take_action()` for `unset` action:
208210
kwargs['example_property'] = \
209211
list(set(resource_example_property) - \
210212
set(parsed_args.example_property))
211-
if parsed_args.no_example_property:
213+
if parsed_args.all_example_property:
212214
kwargs['example_property'] = []
213215
214216
Required Options

0 commit comments

Comments
 (0)