An option with extra args and attributes to control CLI help options grouping, co-required and conflicting options (e.g. mutually exclusive). This option is also pluggable e.g. providable by a plugin.
| 428 | |
| 429 | |
| 430 | class PluggableCommandLineOption(click.Option): |
| 431 | """ |
| 432 | An option with extra args and attributes to control CLI help options |
| 433 | grouping, co-required and conflicting options (e.g. mutually exclusive). |
| 434 | This option is also pluggable e.g. providable by a plugin. |
| 435 | """ |
| 436 | |
| 437 | # args are from Click 6.7 |
| 438 | def __init__( |
| 439 | self, |
| 440 | param_decls=None, |
| 441 | show_default=False, |
| 442 | prompt=False, |
| 443 | confirmation_prompt=False, |
| 444 | hide_input=False, |
| 445 | is_flag=None, |
| 446 | flag_value=UNSET, |
| 447 | multiple=False, |
| 448 | count=False, |
| 449 | allow_from_autoenv=True, |
| 450 | type=None, # NOQA |
| 451 | help=None, # NOQA |
| 452 | hidden=False, |
| 453 | # custom additions # |
| 454 | # a string that set the CLI help group for this option |
| 455 | help_group=MISC_GROUP, |
| 456 | # a relative sort order number (integer or float) for this |
| 457 | # option within a help group: the sort is by increasing |
| 458 | # sort_order then by option declaration. |
| 459 | sort_order=100, |
| 460 | # a sequence of other option name strings that this option |
| 461 | # requires to be set |
| 462 | required_options=(), |
| 463 | # a sequence of other option name strings that this option |
| 464 | # conflicts with if they are set |
| 465 | conflicting_options=(), |
| 466 | **kwargs, |
| 467 | ): |
| 468 | super(PluggableCommandLineOption, self).__init__( |
| 469 | param_decls=param_decls, |
| 470 | show_default=show_default, |
| 471 | prompt=prompt, |
| 472 | confirmation_prompt=confirmation_prompt, |
| 473 | hide_input=hide_input, |
| 474 | is_flag=is_flag, |
| 475 | flag_value=flag_value, |
| 476 | multiple=multiple, |
| 477 | count=count, |
| 478 | allow_from_autoenv=allow_from_autoenv, |
| 479 | type=type, |
| 480 | help=help, |
| 481 | **kwargs, |
| 482 | ) |
| 483 | |
| 484 | self.help_group = help_group |
| 485 | self.sort_order = sort_order |
| 486 | self.required_options = required_options |
| 487 | self.conflicting_options = conflicting_options |
no outgoing calls
no test coverage detected