idiap_devtools.click#
Functions
|
Callback for click doing a profile name validation. |
|
Click-option decorator that adds a |
Classes
|
Class that handles prefix aliasing for commands. |
|
A click command that preserves text indentation. |
- idiap_devtools.click.verbosity_option(logger, short_name='v', name='verbose', dflt=0, **kwargs)[source]#
Click-option decorator that adds a
-v
/--verbose
option to a cli.This decorator adds a click option to your CLI to set the log-level on a provided
logging.Logger
. You must specifically determine the logger that will be affected by this CLI option, via thelogger
option.@verbosity_option(logger=logger)
The verbosity option has the “count” type, and has a default value of 0. At each time you provide
-v
options on the command-line, this value is increased by one. For example, a CLI setting of-vvv
will set the value of this option to 3. This is the mapping between the value of this option (count of-v
CLI options passed) and the log-level set at the provided logger:0 (no
-v
option provided):logger.setLevel(logging.ERROR)
1 (
-v
):logger.setLevel(logging.WARNING)
2 (
-vv
):logger.setLevel(logging.INFO)
3 (
-vvv
or more):logger.setLevel(logging.DEBUG)
- Parameters:
logger (
Logger
) – Thelogging.Logger
to be set.short_name (
str
) – Short name of the option. If not set, then usev
name (
str
) – Long name of the option. If not set, then useverbose
– this will also become the name of the contextual parameter for click.dlft – The default verbosity level to use (defaults to 0).
**kwargs (
Any
) – Further keyword-arguments to be forwarded to the underlyingclick.option()
- Return type:
- Returns:
A callable, that follows the
click
-framework policy for option decorators. Use it accordingly.
- class idiap_devtools.click.AliasedGroup(name=None, commands=None, **attrs)[source]#
Bases:
Group
Class that handles prefix aliasing for commands.
- class idiap_devtools.click.PreserveIndentCommand(name, context_settings=None, callback=None, params=None, help=None, epilog=None, short_help=None, options_metavar='[OPTIONS]', add_help_option=True, no_args_is_help=False, hidden=False, deprecated=False)[source]#
Bases:
Command
A click command that preserves text indentation.
- format_epilog(_, formatter)[source]#
Formats the command epilog during –help.
- Parameters:
_ – The current parsing context
formatter (
HelpFormatter
) – The formatter to use for printing text
- Return type:
- format_description(_, formatter)[source]#
Formats the command description during –help.
- Parameters:
_ – The current parsing context
formatter (
HelpFormatter
) – The formatter to use for printing text
- Return type: