Update devref about "--no-property"
Update the example about "--no-property" and "--property" to make help message order more reasonable, that help make users aware of the processing order, and update the help details when both "--no-property" and "--property" appear in the same command. Change-Id: I998cdaf2f8c881dce219581ff328a639e8e358ee Implements: blueprint allow-overwrite-set-options
This commit is contained in:
parent
607f31d3db
commit
274687d852
@ -153,6 +153,15 @@ An example parser declaration for `set` action:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
parser.add_argument(
|
||||
'--no-example-property',
|
||||
dest='no_example_property',
|
||||
action='store_true',
|
||||
help=_('Remove all example properties for this <resource> '
|
||||
'(specify both --no-example-property and --example-property'
|
||||
' to remove the current properties before setting'
|
||||
' new properties.)'),
|
||||
)
|
||||
parser.add_argument(
|
||||
'--example-property',
|
||||
metavar='<example-property>',
|
||||
@ -161,26 +170,21 @@ An example parser declaration for `set` action:
|
||||
help=_('Example property for this <resource> '
|
||||
'(repeat option to set multiple properties)'),
|
||||
)
|
||||
parser.add_argument(
|
||||
'--no-example-property',
|
||||
dest='no_example_property',
|
||||
action='store_true',
|
||||
help=_('Remove all example properties for this <resource> '
|
||||
'(specify both --example-property and --no-example-property'
|
||||
' to overwrite the current example properties)'),
|
||||
)
|
||||
|
||||
Please make `--no-example-property` be shown in front of `--example-property`
|
||||
in the help, like above, that help make users aware of the processing order.
|
||||
|
||||
An example handler in `take_action()` for `set` action:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
if parsed_args.example_property and parsed_args.no_example_property:
|
||||
if parsed_args.no_example_property and parsed_args.example_property:
|
||||
kwargs['example_property'] = parsed_args.example_property
|
||||
elif parsed_args.no_example_property:
|
||||
kwargs['example_property'] = []
|
||||
elif parsed_args.example_property:
|
||||
kwargs['example_property'] = \
|
||||
resource_example_property + parsed_args.example_property
|
||||
elif parsed_args.no_example_property:
|
||||
kwargs['example_property'] = []
|
||||
|
||||
An example parser declaration for `unset` action:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user