Commit 4549c368 authored by Jan Reimes's avatar Jan Reimes
Browse files

feat(cli): add configuration management commands and constants

* Introduced config_app for managing configuration via CLI.
* Added constants for help panels and section descriptions.
* Updated imports in CLI modules to reflect new structure.
* Enhanced spec_app and tdoc_app to include configuration management.
parent d15c7155
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
from __future__ import annotations

from tdoc_crawler.cli.config import load_cli_config
from tdoc_crawler.cli.config_cmd import config_app
from tdoc_crawler.cli.config_app import config_app
from tdoc_crawler.cli.spec_app import spec_app
from tdoc_crawler.cli.tdoc_app import tdoc_app

+5 −13
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ from rich import print as rprint
from rich.console import Console
from rich.table import Table

from tdoc_crawler.cli.constants import HELP_PANEL_CONFIG, SECTION_DESCRIPTIONS
from tdoc_crawler.config.export import ConfigExporter
from tdoc_crawler.config.settings import TDocCrawlerConfig

@@ -53,7 +54,7 @@ ConfigDocsSectionOption = Annotated[
config_app = typer.Typer(help="Manage configuration")


@config_app.command("init")
@config_app.command("init", rich_help_panel=HELP_PANEL_CONFIG)
def config_init(
    output: ConfigInitOutputOption,
    format: ConfigInitFormatOption = "toml",
@@ -70,7 +71,7 @@ def config_init(
        raise typer.Exit(1)


@config_app.command("show")
@config_app.command("show", rich_help_panel=HELP_PANEL_CONFIG)
def config_show(
    format: ConfigShowFormatOption = "toml",
) -> None:
@@ -79,15 +80,6 @@ def config_show(
    print(exporter.export(format))


# Section help text mapping
SECTION_DESCRIPTIONS = {
    "path": "File system paths (cache_dir, db_file, checkout_dir, ai_cache_dir)",
    "http": "HTTP client settings (timeout, retries, caching, SSL)",
    "credentials": "ETSI Online portal credentials (username, password)",
    "crawl": "Crawling filters and limits (working_group, date range, workers)",
}


def _check_path_exists(path: Path) -> tuple[bool, str]:
    """Check if a path exists or can be created."""
    if path.exists():
@@ -205,7 +197,7 @@ def _display_validation_results(issues: list[tuple[str, str]], strict: bool) ->
    raise typer.Exit(3)


@config_app.command("validate")
@config_app.command("validate", rich_help_panel=HELP_PANEL_CONFIG)
def config_validate(
    file: ConfigValidateFileOption = None,
    strict: ConfigValidateStrictOption = False,
@@ -236,7 +228,7 @@ def config_validate(
    _display_validation_results(issues, strict)


@config_app.command("docs")
@config_app.command("docs", rich_help_panel=HELP_PANEL_CONFIG)
def config_docs(
    section: ConfigDocsSectionOption = None,
) -> None:
+14 −0
Original line number Diff line number Diff line
"""Shared constants for the CLI."""

HELP_PANEL_MAIN = "Main Commands"
HELP_PANEL_CRAWLING = "Crawling Commands"
HELP_PANEL_QUERY = "Query Commands"
HELP_PANEL_CONFIG = "Configuration Commands"

# Section help text mapping
SECTION_DESCRIPTIONS = {
    "path": "File system paths (cache_dir, db_file, checkout_dir, ai_cache_dir)",
    "http": "HTTP client settings (timeout, retries, caching, SSL)",
    "credentials": "ETSI Online portal credentials (username, password)",
    "crawl": "Crawling filters and limits (working_group, date range, workers)",
}
+5 −5
Original line number Diff line number Diff line
@@ -7,9 +7,11 @@ from typing import Annotated

import typer

from tdoc_crawler.cli import config_app
from tdoc_crawler.cli._shared import console
from tdoc_crawler.cli.args import CacheDirOption, VerbosityOption
from tdoc_crawler.cli.config import load_cli_config
from tdoc_crawler.cli.constants import HELP_PANEL_CRAWLING, HELP_PANEL_MAIN, HELP_PANEL_QUERY
from tdoc_crawler.cli.crawl import crawl_specs
from tdoc_crawler.cli.query import query_specs
from tdoc_crawler.cli.specs import checkout_spec, open_spec
@@ -17,12 +19,10 @@ from tdoc_crawler.config import CacheManager
from tdoc_crawler.logging import DEFAULT_LEVEL as DEFAULT_VERBOSITY
from tdoc_crawler.logging import set_verbosity

spec_app = typer.Typer(help="3GPP Crawler - Technical Specifications")

HELP_PANEL_MAIN = "Main Commands"
HELP_PANEL_CRAWLING = "Crawling Commands"
HELP_PANEL_QUERY = "Query Commands"
spec_app = typer.Typer(help="3GPP Crawler for Technical Specifications/Reports")

# Register config sub-app
spec_app.add_typer(config_app, name="config", help="Manage configuration")

@spec_app.callback()
def _spec_app_callback(
+2 −9
Original line number Diff line number Diff line
@@ -23,7 +23,8 @@ from tdoc_crawler.cli.args import (
    VerbosityOption,
)
from tdoc_crawler.cli.config import load_cli_config
from tdoc_crawler.cli.config_cmd import config_app
from tdoc_crawler.cli.config_app import config_app
from tdoc_crawler.cli.constants import HELP_PANEL_CRAWLING, HELP_PANEL_MAIN, HELP_PANEL_QUERY
from tdoc_crawler.cli.crawl import crawl_meetings, crawl_tdocs
from tdoc_crawler.cli.query import query_meetings, query_tdocs
from tdoc_crawler.cli.utils import launch_file
@@ -41,14 +42,6 @@ from tdoc_crawler.utils.normalization import normalize_tdoc_id, normalize_tdoc_i
tdoc_app = typer.Typer(help="3GPP Crawler - TDocs and Meetings")


HELP_PANEL_MAIN = "Main Commands"

HELP_PANEL_CRAWLING = "Crawling Commands"

HELP_PANEL_QUERY = "Query Commands"

HELP_PANEL_CONFIG = "Configuration Commands"

# Register config sub-app
tdoc_app.add_typer(config_app, name="config", help="Manage configuration")