Skip to content

Commit

Permalink
Auto formatted CLI params
Browse files Browse the repository at this point in the history
  • Loading branch information
devmaxde committed Nov 28, 2024
1 parent 4fc50bc commit 3e5f5a4
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions metricq/cli/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:**
Expand Down Expand Up @@ -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'.
Expand All @@ -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.
Expand All @@ -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")
Expand All @@ -150,9 +152,8 @@ def dummy(
if __name__ == "__main__":
dummy()
..
..
"""
logger = get_metric_command_logger()

Expand Down

0 comments on commit 3e5f5a4

Please sign in to comment.