File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -211,6 +211,36 @@ An example handler in `take_action()` for `unset` action:
211211 if parsed_args.no_example_property:
212212 kwargs[' example_property' ] = []
213213
214+ Required Options
215+ ----------------
216+
217+ Some options have no default value and the API does not allow them to be
218+ `None `, then these options are always required when users use the command
219+ to which these options belong.
220+
221+ Required options must be validated by the CLI to aviod omissions. The CLI
222+ validation may provide an error message for the user if a required option
223+ is not specified.
224+ (for example: ``error: argument --test is required ``)
225+
226+ .. option :: --test
227+
228+ Test option (required)
229+
230+ Implementation
231+ ~~~~~~~~~~~~~~
232+
233+ The parser declaration should look like this:
234+
235+ .. code-block :: python
236+
237+ parser.add_argument(
238+ ' --test' ,
239+ metavar = ' <test>' ,
240+ required = True ,
241+ help = _(' Test option (required)' ),
242+ )
243+
214244 List Command Options
215245====================
216246
You can’t perform that action at this time.
0 commit comments