diff options
| author | Rui Chen <chenrui.momo@gmail.com> | 2016-09-23 15:26:48 +0800 |
|---|---|---|
| committer | Rui Chen <chenrui.momo@gmail.com> | 2016-10-10 09:36:47 +0800 |
| commit | 29f78500dba1aa258e4e94e331a7a48c38ce58e2 (patch) | |
| tree | f59d54e54f03b1f85115f0726a3f3a2eaed18640 | |
| parent | 762f2f2c34814b8bfc615696918d8cb49b93a1dd (diff) | |
| download | python-openstackclient-29f78500dba1aa258e4e94e331a7a48c38ce58e2.tar.gz | |
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
| -rw-r--r-- | doc/source/command-options.rst | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/doc/source/command-options.rst b/doc/source/command-options.rst index a833d1d5..c850b000 100644 --- a/doc/source/command-options.rst +++ b/doc/source/command-options.rst @@ -118,12 +118,12 @@ Some options can be repeated to build a collection of values for a property. Adding a value to the collection must be provided via the ``set`` action. Removing a value from the collection must be provided via an ``unset`` action. As a convenience, removing all values from the collection may be provided via a -``--no`` option on the ``set`` and ``unset`` actions. If both ``--no`` option -and option are specified, the values specified on the command would overwrite -the collection property instead of appending on the ``set`` action. The -``--no`` option must be part of a mutually exclusive group with the related -property option on the ``unset`` action, overwrite case don't exist in -``unset`` action. +``--no`` option on the ``set`` action and a ``--all`` option on ``unset`` +action. If both ``--no`` option and option are specified, the values specified +on the command would overwrite the collection property instead of appending on +the ``set`` action. The ``--all`` option must be part of a mutually exclusive +group with the related property option on the ``unset`` action, overwrite case +don't exist in ``unset`` action. An example behavior for ``set`` action: @@ -165,7 +165,9 @@ An example parser declaration for `set` action: '--no-example-property', dest='no_example_property', action='store_true', - help=_('Remove all example properties for this <resource>'), + help=_('Remove all example properties for this <resource> ' + '(specify both --example-property and --no-example-property' + ' to overwrite the current example properties)'), ) An example handler in `take_action()` for `set` action: @@ -194,8 +196,8 @@ An example parser declaration for `unset` action: '(repeat option to remove multiple properties)'), ) example_property_group.add_argument( - '--no-example-property', - dest='no_example_property', + '--all-example-property', + dest='all_example_property', action='store_true', help=_('Remove all example properties for this <resource>'), ) @@ -208,7 +210,7 @@ An example handler in `take_action()` for `unset` action: kwargs['example_property'] = \ list(set(resource_example_property) - \ set(parsed_args.example_property)) - if parsed_args.no_example_property: + if parsed_args.all_example_property: kwargs['example_property'] = [] Required Options |
