-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Documentation for metricq_command
- Loading branch information
Showing
4 changed files
with
115 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
CLI | ||
================================== | ||
|
||
|
||
|
||
This package provides CLI utilities and decorators for MetricQ applications, including custom parameter types for choices, durations, timestamps, templates, and metrics. | ||
|
||
To use this part of the package you need to install additional dependencies. You can install the dependencies using the following command: | ||
|
||
.. code-block:: bash | ||
pip install "metricq[cli]" | ||
.. | ||
Wrapper | ||
------------------ | ||
|
||
@metricq_command | ||
^^^^^^^^^^^^^^^^^^ | ||
|
||
Decorates a function to create a MetricQ CLI command with options for server and token configuration. | ||
Server and Token must be in the right order. | ||
|
||
**Parameters** | ||
|
||
- **default_token** (`str`): The default client token for the MetricQ network. | ||
|
||
**Usage** | ||
|
||
.. code-block:: python | ||
@metricq_command(default_token="example.program") | ||
def example( | ||
server: str, token: str | ||
) -> None: | ||
pass | ||
if __name__ == "__main__": | ||
example() | ||
.. | ||
|
||
@metricq_metric_option | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
Defines an option for specifying one or more metrics. Should be used in combination with @metricq_command(). | ||
If multiple is set to true, the return type changes to List[metric] | ||
|
||
**Parameters** | ||
|
||
- **default** (`Optional[str]`, optional): The default metric. Defaults to `None`. | ||
- **multiple** (`bool`, optional): If `True`, allows multiple metrics to be specified. Defaults to `False`. | ||
- **required** (`bool`, optional): If `True`, makes the option required. Defaults to `False`. | ||
|
||
**Usage** | ||
|
||
.. code-block:: python | ||
@metricq_command(default_token="example.program") | ||
@metricq_metricq_option(required=true, default="example.metric") | ||
def metric_example( | ||
server: str, token: str, metric: Metric | ||
) -> None: | ||
pass | ||
@metricq_command(default_token="example.program") | ||
@metricq_metricq_option(required=true, multiple=True) # <-- multiple is set | ||
def multi_metric_example( | ||
server: str, token: str, metric: List[Metric] | ||
) -> None: | ||
pass | ||
.. | ||
Parameter | ||
---------------- | ||
|
||
.. automodule:: metricq.cli.params | ||
:members: | ||
:exclude-members: get_metavar, convert, name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ API Reference | |
client-common | ||
exceptions | ||
misc | ||
cli |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters