Skip to content

feat: add local config commands (list versions, download XML) #213

Description

@cdot65

Overview

Add scm local command group for listing device configuration versions and downloading config files as XML. Wraps the new client.local_config service from SDK 0.13.0.

Context

SDK 0.13.0 adds client.local_config with:

  • List versions: Get configuration version history for a device
  • Download config: Download a specific config version as raw XML (uses raw_response for binary download)
  • Pydantic models for local config version data

Dependencies

Design Decisions (from brainstorming session 2026-04-16)

  1. Top-level command group: scm local list and scm local download (not nested under existing groups)
  2. Download output: Default to stdout, --output <path> writes to file
  3. Follows existing CLI patterns: Typer app, @handle_command_errors, consistent option naming

Scope

  • In scope:
    • New command module: src/scm_cli/commands/local.py
    • Subcommands: scm local list --device <name> and scm local download --device <name> --version <id> [--output config.xml]
    • SDK client methods in sdk_client.py: list_local_config_versions(), download_local_config()
    • Validator models in validators.py (if needed for input validation)
    • Mock mode support with realistic sample data
    • Register in main.py as top-level command group
    • Tests: tests/test_local_commands.py
    • Documentation: docs/cli/local/ pages
    • Update mkdocs.yml nav
  • Out of scope:
    • Device operations commands (see separate issue)
    • Config diff/comparison features (future enhancement)

CLI Interface

# List config versions for a device
scm local list --device fw-01

# Download a specific version to stdout
scm local download --device fw-01 --version 42

# Download to a file
scm local download --device fw-01 --version 42 --output fw-01-v42.xml

# Mock mode
scm local list --device fw-01 --mock

Acceptance Criteria

  • src/scm_cli/commands/local.py exists with list and download subcommands
  • scm local list --device <name> shows config versions in table format
  • scm local download --device <name> --version <id> outputs XML to stdout
  • scm local download --output <path> writes XML to file
  • SDK client methods added with proper error handling
  • Mock mode returns realistic sample config version data
  • Unit tests in tests/test_local_commands.py covering list, download-to-stdout, download-to-file, error cases
  • Documentation pages created and linked in mkdocs.yml
  • make quality passes
  • Module follows style guide (191-char separators, Google docstrings, section organization)

Implementation Notes

  • Download uses raw_response=True in Scm.request() — the response body is raw XML bytes
  • For stdout output, decode XML as UTF-8; for file output, write binary
  • Table columns for list: version number, date, author/source, description (based on SDK model fields)
  • Follow commands/jobs.py as a pattern reference — similar "list + show detail" structure

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions