Skip to content

Add JSON and CSV output to --stats #327

Open

Description

@somethingwithproof

Problem

commitkit --stats (src/stats.rs, CommitAnalyzer::get_type_summary) only returns a formatted text block, and it truncates scopes and contributors to the top five. CommitStats already holds the full type, scope, contributor and per-date counts, but none of that can be consumed by a script or dashboard.

Proposal

Add --format <text|json|csv> (default text) used with --stats. JSON emits the whole CommitStats struct, including commits_by_date, with keys sorted for stable output. CSV emits dimension,key,count rows for type, scope, contributor and date. Text output stays as it is. Output goes to stdout so it can be redirected.

Where it fits

src/stats.rs (derive Serialize on CommitStats, add a render function beside get_type_summary), src/main.rs (new --format arg), Cargo.toml if serde_json is not already a dependency.

Done when

  • commitkit --stats --format json prints valid JSON containing all four count maps.
  • --format csv prints a header row and one row per count.
  • Default output is unchanged.
  • --days applies to all formats.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions