Skip to content

Add --staged and --diff flags for git workflows #20

@jakekaplan

Description

@jakekaplan

Summary

Add git-aware flags to reduce shell piping in common CI/pre-commit workflows.

Motivation

Currently users must pipe git output:

git diff --name-only main | loq check -

Native flags make the common case easy:

loq check --staged
loq check --diff main

Design

New flags (on check command):

  • --staged - Check only files in the git staging area
  • --diff <ref> - Check files changed since ref (e.g., main, origin/main..HEAD)

Behavior with paths: Intersect

  • loq check src/ --staged checks only staged files within src/
  • This is the most intuitive behavior

Git not available: Hard error with helpful message

  • "error: --staged requires git, but git is not available"

Implementation notes:

  • Shell out to git diff --name-only under the hood
  • Reuse existing stdin/path-list logic
  • Filter to only files (not directories) that exist

Tasks

  • Add --staged flag to check command
  • Add --diff <ref> flag to check command
  • Implement git command execution
  • Handle intersection with path arguments
  • Add clear error when git unavailable
  • Integration tests for git workflows
  • Document in README

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions