Skip to content

feat: implement CLI argument parsing - #13

Merged
unhappychoice merged 1 commit into
mainfrom
feat/cli-argument-parsing
Nov 8, 2025
Merged

unhappychoice merged 1 commit into
mainfrom
feat/cli-argument-parsing

Conversation

@unhappychoice

@unhappychoice unhappychoice commented Nov 8, 2025 •

Copy link
Copy Markdown
Owner

Summary

Implement command-line interface with clap for git-logue.

Changes

  • Add Args struct with clap derive macro:
    • --path <PATH>: specify Git repository path (defaults to current directory)
    • --commit <HASH>: replay specific commit for single-commit mode
    • --speed <MS>: typing speed in milliseconds per character (default: 30)
  • Add validation method that:
    • Checks if path exists
    • Verifies path is a Git repository (has .git directory)
    • Canonicalizes repository path
  • Add help text and usage examples

Test plan

  • cargo build succeeds
  • --help displays usage information
  • Default behavior uses current directory
  • Custom options (--speed, --commit) work correctly
  • Validation catches non-existent paths
  • Validation catches non-Git directories

Example usage

# Default: current directory, random commits, 30ms speed
git-logue

# Specific repository
git-logue --path /path/to/repo

# Single commit mode
git-logue --commit abc123

# Custom typing speed
git-logue --speed 50

Resolves #3

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features
    • Added command-line argument support to specify repository path, commit reference, and speed parameter.
    • Implemented path validation with enhanced error messages to ensure repository integrity.
    • Enhanced startup output to display repository path, speed setting, and operational mode.

Add command-line interface with clap:
- --path: specify Git repository path (defaults to current directory)
- --commit: replay specific commit (single-commit mode)
- --speed: typing speed in milliseconds per character (default: 30)

Includes validation:
- Check if path exists
- Verify path is a Git repository
- Canonicalize repository path

Resolves #3

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 8, 2025 •

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request introduces CLI argument parsing using Clap framework to src/main.rs. It adds a public Args struct with fields for repository path, commit hash, and speed, along with a validate() method that verifies the path is a valid Git repository and canonicalizes it with contextual error handling. The main function now parses arguments, validates paths, and prints runtime information.

Changes

Cohort / File(s) Summary
CLI argument parsing and validation
src/main.rs
Introduces Args struct with path, commit, and speed fields derived with Clap Parser. Adds validate() method to verify repository path existence, .git directory presence, and path canonicalization. Enhances main function to parse arguments and print runtime information. Expands imports for Clap, PathBuf, and error handling Context.

Sequence Diagram

sequenceDiagram
    participant main as main()
    participant clap as Clap Parser
    participant args as Args
    participant fs as File System
    participant app as Application Logic

    main->>clap: Parse command-line arguments
    clap-->>args: Return Args struct
    main->>args: Call validate()
    args->>fs: Check path exists
    alt Path exists
        args->>fs: Check .git directory
        alt .git found
            args->>fs: Canonicalize path
            args-->>main: Return canonicalized PathBuf
            main->>main: Print runtime info<br/>(path, speed, mode)
            main->>app: Continue with main logic
        else .git not found
            args-->>main: Return error (not a Git repo)
        end
    else Path not found
        args-->>main: Return error (path invalid)
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Single file modification with straightforward, linear logic in validation method
  • Standard Clap pattern following conventional derive macro usage
  • Clear error handling with contextual messages
  • Minor expansion of main function flow with no complex control logic

Poem

🐰 Hops through the arguments with Clap so fine,
Validates the .git, makes paths align,
Speeds and commits in a struct so neat,
CLI parsing—our feature's complete! ✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/cli-argument-parsing

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4861a11 and 2841866.

📒 Files selected for processing (1)
  • src/main.rs (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@unhappychoice
unhappychoice merged commit a10b823 into main Nov 8, 2025
@unhappychoice
unhappychoice deleted the feat/cli-argument-parsing branch November 8, 2025 21:55
@coderabbitai coderabbitai Bot mentioned this pull request Nov 11, 2025
7 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement CLI argument parsing

1 participant