Coverage for .tox/coverage/lib/python3.11/site-packages/wuttatell/cli/tell.py: 100%
17 statements
« prev ^ index » next coverage.py v7.10.2, created at 2025-08-31 12:53 -0500
« prev ^ index » next coverage.py v7.10.2, created at 2025-08-31 12:53 -0500
1# -*- coding: utf-8; -*-
2################################################################################
3#
4# WuttaTell -- Telemetry submission for Wutta Framework
5# Copyright © 2025 Lance Edgar
6#
7# This file is part of Wutta Framework.
8#
9# Wutta Framework is free software: you can redistribute it and/or modify it
10# under the terms of the GNU General Public License as published by the Free
11# Software Foundation, either version 3 of the License, or (at your option) any
12# later version.
13#
14# Wutta Framework is distributed in the hope that it will be useful, but
15# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17# more details.
18#
19# You should have received a copy of the GNU General Public License along with
20# Wutta Framework. If not, see <http://www.gnu.org/licenses/>.
21#
22################################################################################
23"""
24See also: :ref:`wutta-tell`
25"""
27import logging
29import typer
30from typing_extensions import Annotated
32from wuttjamaican.cli import wutta_typer
35log = logging.getLogger(__name__)
38@wutta_typer.command()
39def tell(
40 ctx: typer.Context,
41 profile: Annotated[
42 str,
43 typer.Option(
44 "--profile",
45 "-p",
46 help="Profile (type) of telemetry data to collect. "
47 "This also determines where/how data is submitted. "
48 "If not specified, default profile is assumed.",
49 ),
50 ] = None,
51 dry_run: Annotated[
52 bool,
53 typer.Option(
54 "--dry-run",
55 help="Go through all the motions but do not submit " "the data to server.",
56 ),
57 ] = False,
58):
59 """
60 Collect and submit telemetry data
61 """
62 config = ctx.parent.wutta_config
63 app = config.get_app()
64 telemetry = app.get_telemetry_handler()
66 data = telemetry.collect_all_data(profile=profile)
67 log.info("data collected for: %s", ", ".join(sorted(data)))
68 log.debug("%s", data)
70 if dry_run:
71 log.info("dry run, so will not submit data to server")
72 else:
73 telemetry.submit_all_data(profile=profile, data=data)
74 log.info("data submitted okay")