From 3e5f5a41dc67e99bea9d9f0d6e99f6213d7b159a Mon Sep 17 00:00:00 2001 From: Max Kutschka <2004maximilian@web.de> Date: Thu, 28 Nov 2024 13:34:45 +0100 Subject: [PATCH] Auto formatted CLI params --- metricq/cli/wrapper.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/metricq/cli/wrapper.py b/metricq/cli/wrapper.py index 5666e8e8..624e5f20 100644 --- a/metricq/cli/wrapper.py +++ b/metricq/cli/wrapper.py @@ -48,11 +48,10 @@ def metricq_metric_option( The metric option can be used to select one or more metrics the program should use. The metric can be set with the -\\-metric or -m parameter. If no default value is set, the parameter is required. The metric input must follow the specification (``([a-zA-Z][a-zA-Z0-9_]+\\.)+[a-zA-Z][a-zA-Z0-9_]+``). - **Parameter** - - - **default** (`Optional[str]`, optional): The default metric. Defaults to `None`. You can only set one default, even if the program allows multiple inputs. - - **multiple** (`bool`, optional): If `True`, allows multiple metrics to be specified. Defaults to `False`. - - **required** (`bool`, optional): If `True`, makes the -\\-metric option required. Defaults to `False`. If required is set and no default is provided, at least one metric input is required. + Args: + default: The default metric. Defaults to `None`. You can only set one default, even if the program allows multiple inputs. + multiple: If `True`, allows multiple metrics to be specified. Defaults to `False`. + required: If `True`, makes the -\\-metric option required. Defaults to `False`. If required is set and no default is provided, at least one metric input is required. **example implementation:** @@ -109,7 +108,15 @@ def get_metric_command_logger() -> logging.Logger: def metricq_command( default_token: str, client_version: str | None = None ) -> Callable[[FC], click.Command]: - """ + """Standardized wrapper for click commands + + Args: + default_token: default token that will be used if no token is provided + client_version: version of the client + + Returns: + Callable[[FC], click.Command]: click command + The @metricq_command is the first parameter of any given click/cli command. The main purpose is to provide the most used parameters. These parameters are 'server', 'token' and 'syslog'. @@ -122,6 +129,7 @@ def metricq_command( The Token is used to identify each program on the metricq network. for example: sink-py-dummy The token param can be set using the environment variable METRICQ_TOKEN or adding the --token {value} option to the cli command + - -\\-syslog: The Syslog param is used to enable syslog. It can be used with or without parameter. @@ -132,12 +140,6 @@ def metricq_command( Full example: ``metricq-check --server amqp://localhost/ --token sink-py-dummy --syslog`` - **Parameters** - - - **default_token** (`str`): The default token can be set by the developer to reduce the required params when calling the program. The token can be overwritten by using the -\\-token or environment variable. If no default token is set, the -\\-token input is required to run the program. - - **example implementation:** - .. code-block:: python @metricq_command(default_token="source-py-dummy") @@ -150,9 +152,8 @@ def dummy( if __name__ == "__main__": dummy() -.. - + .. """ logger = get_metric_command_logger()