summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorHuanxuan Ao <huanxuan.ao@easystack.cn>2016-07-27 15:35:58 +0800
committerHuanxuan Ao <huanxuan.ao@easystack.cn>2016-08-02 19:54:30 +0800
commitc1a040f66d80c7f4c554938a71d985a41b1871bf (patch)
tree57ac5143406b86f0c0b83f81b3e25dd05d396aab /doc
parent97ccb65f8391a54c00f8f43e74f69941e7a4736c (diff)
downloadpython-openstackclient-c1a040f66d80c7f4c554938a71d985a41b1871bf.tar.gz
Add a document for required options
Some options are required in some commands, I think we need a document to state what should we do in this case. Change-Id: Id345ca1790e2125b333b271b74288e1a73d39ba3
Diffstat (limited to 'doc')
-rw-r--r--doc/source/command-options.rst30
1 files changed, 30 insertions, 0 deletions
diff --git a/doc/source/command-options.rst b/doc/source/command-options.rst
index 6260ec32..ebfeb5aa 100644
--- a/doc/source/command-options.rst
+++ b/doc/source/command-options.rst
@@ -211,6 +211,36 @@ An example handler in `take_action()` for `unset` action:
if parsed_args.no_example_property:
kwargs['example_property'] = []
+Required Options
+----------------
+
+Some options have no default value and the API does not allow them to be
+`None`, then these options are always required when users use the command
+to which these options belong.
+
+Required options must be validated by the CLI to aviod omissions. The CLI
+validation may provide an error message for the user if a required option
+is not specified.
+(for example: ``error: argument --test is required``)
+
+.. option:: --test
+
+ Test option (required)
+
+Implementation
+~~~~~~~~~~~~~~
+
+The parser declaration should look like this:
+
+.. code-block:: python
+
+ parser.add_argument(
+ '--test',
+ metavar='<test>',
+ required=True,
+ help=_('Test option (required)'),
+ )
+
List Command Options
====================