Skip to content

Standardize CLI output, logging, and progress indication across all scripts #319

@turbomam

Description

@turbomam

Background

The metpo codebase currently has inconsistent patterns for:

  • Terminal output: Some scripts use click.echo(), others use rich.console.Console
  • Logging: Mix of standard logging module and ad-hoc approaches
  • Progress indication: Some use tqdm, others use rich progress bars or nothing
  • Table display: Some use rich.table.Table, others print plain text

Current State

Existing metpo scripts (metpo/scripts/*.py, metpo/bactotraits/*.py, etc.):

  • Output: click.echo()
  • Progress: tqdm
  • Logging: standard logging

Newly added madin scripts (metpo/scripts/madin/*.py):

  • Output: rich.console.Console with markup
  • Tables: rich.table.Table
  • Logging: custom get_logger() wrapper

Proposal

Establish and document a consistent pattern for all CLI scripts:

  1. Output: Choose one of:

    • click.echo() (simpler, no color)
    • rich.console.Console (richer formatting)
  2. Logging: Standardize on:

    • Standard logging module with consistent format
    • Or rich's logging handler for colored logs
  3. Progress: Choose one of:

    • tqdm (widely used)
    • rich.progress (integrates with rich console)
  4. Tables: Choose one of:

    • Plain text / TSV output
    • rich.table.Table for terminal display

Tasks

  • Document the chosen patterns in CLAUDE.md
  • Create a shared utility module (e.g., metpo/cli_utils.py) with standard helpers
  • Refactor existing scripts to use the standard patterns
  • Update madin scripts to match

Related

  • Added rich>=13.0.0 as a dependency to support madin scripts
  • Scripts imported from biosample-enricher PR Release 2025-09-23 #200

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions