Skip to content

Add get-match command for detailed match information - #4

Merged
mgranderath merged 2 commits into
mainfrom
feature/get-match-command
Feb 1, 2026
Merged

Add get-match command for detailed match information#4
mgranderath merged 2 commits into
mainfrom
feature/get-match-command

Conversation

@mgranderath

@mgranderath mgranderath commented Feb 1, 2026

Copy link
Copy Markdown
Owner

Summary

This PR adds a new get-match command to fetch detailed information for a specific match using the Blast.tv API.

Changes

  • New command: get-match <match-id> - Retrieves detailed match information

    • Supports output formats: table (default), JSON, YAML via -o flag
    • Example: rlcs-cli get-match 667d39fa-65cb-46c1-b939-3554cdbd5cc0 -o json
  • Code reuse:

    • Reuses existing MatchResponse API model from match_models.go
    • Reuses existing domain.Match domain model
    • Reuses all existing output formatters (table, JSON, YAML)
    • Follows same patterns as existing commands
  • New mapper function: ToDomainMatchFromDetailResponse() in internal/mapper/match.go

    • Public wrapper around existing private function for single match mapping
  • Test coverage:

    • Command tests: HTTP mocking for success, 404, 500, invalid JSON, different output formats
    • Mapper tests: Full tournament context, null external IDs/metadata, matches with maps
    • All tests passing ✅

API Endpoint

GET https://api.blast.tv/v2/matches/{matchID}/detailed

Testing

go test ./internal/cmd/... ./internal/mapper/... -v

Checklist

  • Command implemented
  • Tests added and passing
  • Code follows existing patterns
  • Reuses existing components where possible

Summary by CodeRabbit

  • New Features

    • Added a new "get-match" CLI command to fetch detailed match information.
    • Output formats: table (default), JSON, and YAML.
  • Refactor

    • CLI now uses a configurable API base URL instead of hardcoded endpoints.
  • Tests

    • Comprehensive test coverage for match retrieval, output formats, and error cases.

✏️ Tip: You can customize this high-level summary in your review settings.

Adds a new command to fetch detailed match information from the API:
- New command: get-match <match-id> with -o flag for output format
- Reuses existing API models, domain models, and output formatters
- Adds ToDomainMatchFromDetailResponse mapper function
- Comprehensive test coverage for command and mapper
- Supports table, JSON, and YAML output formats
@coderabbitai

coderabbitai Bot commented Feb 1, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds a new GetMatch CLI command that requests detailed match data from the Blast API (10s timeout), parses JSON, maps to the domain model, and formats output. Integrates into the root CLI, introduces a mapper wrapper, defines BaseURL constant, and includes comprehensive unit tests and minor URL replacements.

Changes

Cohort / File(s) Summary
GetMatch command
internal/cmd/get_match.go
New GetMatchCmd public struct (MatchID, Output) and Run(ctx *Context) error implementing a 10s GET to /matches/{id}/detailed, response/status handling (404/non-OK), JSON parsing, mapping via ToDomainMatchFromDetailResponse, and output formatting.
GetMatch tests
internal/cmd/get_match_test.go
Adds gock-based tests covering success, 404, 500, invalid JSON, maps payloads, and table/json/yaml outputs; verifies mock consumption and error messages.
CLI root
internal/cmd/root.go
Registers GetMatch GetMatchCmd as new get-match subcommand on the CLI root.
Mapper wrapper
internal/mapper/match.go
Adds exported ToDomainMatchFromDetailResponse(api blast.MatchResponse) (domain.Match, error) delegating to existing mapping logic for single-object responses.
Mapper tests
internal/mapper/match_test.go
Adds table-driven tests for ToDomainMatchFromDetailResponse, covering detailed tournament context, null external IDs, maps handling, and invalid scheduled time errors.
API client base URL
internal/api/blast/client.go
Adds BaseURL constant set to https://api.blast.tv/v2.
URL refactors
internal/cmd/get_brackets.go, internal/cmd/get_matches.go, internal/cmd/list_tournaments.go
Replaces hardcoded https://api.blast.tv/v2 strings with blast.BaseURL in request construction.

Sequence Diagram

sequenceDiagram
    participant User as User/CLI
    participant Cmd as GetMatchCmd
    participant API as Blast API
    participant Parser as JSON Parser
    participant Mapper as Domain Mapper
    participant Formatter as Output Formatter

    User->>Cmd: Run(ctx) with MatchID
    Cmd->>API: GET /matches/{MatchID}/detailed (10s)
    API-->>Cmd: HTTP Response (status + body)
    alt 404
        Cmd-->>User: Error "match not found"
    else Non-OK
        Cmd-->>User: Error "unexpected status code"
    else 200
        Cmd->>Parser: Parse JSON body
        alt parse error
            Parser-->>Cmd: Parse error
            Cmd-->>User: Error "failed to parse JSON"
        else parsed
            Parser-->>Cmd: MatchResponse
            Cmd->>Mapper: ToDomainMatchFromDetailResponse(MatchResponse)
            alt mapping error
                Mapper-->>Cmd: Error
                Cmd-->>User: Error "failed to map match"
            else mapped
                Mapper-->>Cmd: domain.Match
                Cmd->>Formatter: GetMatchesFormatter(Output) -> formatted output
                Formatter-->>User: Formatted match output
            end
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 I hopped to fetch a match today,
From /matches/{id}/detailed I made my way,
Parsed and mapped with nimble feet,
Table, JSON, YAML — all neat! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: adding a new CLI command to fetch detailed match information.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 feature/get-match-command

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.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @mgranderath, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the rlcs-cli tool by introducing a new command, get-match, which allows users to retrieve detailed information about a specific match from the Blast.tv API. The implementation follows established patterns within the project, reusing existing data models and output formatting capabilities. It includes robust error handling for API interactions and comprehensive unit tests to ensure reliability and correctness across various scenarios.

Highlights

  • New Command Added: Introduced a new get-match command to fetch detailed information for a specific match using the Blast.tv API.
  • Output Flexibility: The new command supports various output formats including table (default), JSON, and YAML, configurable via the -o flag.
  • Code Reusability: Leverages existing MatchResponse API and domain.Match models, as well as existing output formatters, ensuring consistency and reducing redundancy.
  • New Mapper Function: A new public mapper function, ToDomainMatchFromDetailResponse(), was added in internal/mapper/match.go to convert a single API match response to the domain model.
  • Comprehensive Testing: Extensive test coverage has been added for both the new command (including HTTP mocking for various response scenarios) and the mapper function (covering different data contexts and edge cases).
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This PR introduces a new get-match command, which is well-implemented and follows existing patterns in the codebase. The test coverage is good, handling various API response scenarios effectively. I have a couple of suggestions to further improve maintainability and test robustness: one regarding a hardcoded API URL, and another to strengthen the tests for JSON/YAML output formats by verifying the actual output content.

Comment thread internal/cmd/get_match.go Outdated
}

func (g *GetMatchCmd) Run(ctx *Context) error {
url := fmt.Sprintf("https://api.blast.tv/v2/matches/%s/detailed", g.MatchID)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The API base URL https://api.blast.tv is hardcoded. To improve maintainability and avoid duplication, consider defining this as a package-level constant. This would make it easier to update the API endpoint in the future and ensure consistency across the application, especially since it's also used in the test file.

For example, you could add this at the package level:

const blastAPIBaseURL = "https://api.blast.tv"

And then use it here:

url := fmt.Sprintf("%s/v2/matches/%s/detailed", blastAPIBaseURL, g.MatchID)

Comment on lines +210 to +211
err := cmd.Run(ctx)
assert.NoError(t, err)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This test could be more robust. It currently only checks that the command runs without error. It should also verify that the HTTP mock was consumed (gock.IsDone()) and that valid JSON was written to standard output. This feedback also applies to the 'YAML output format' test.

You will need to add os, io, and encoding/json to your imports to apply this suggestion.

		oldStdout := os.Stdout
		r, w, _ := os.Pipe()
		os.Stdout = w

		err := cmd.Run(ctx)

		w.Close()
		out, _ := io.ReadAll(r)
		os.Stdout = oldStdout

		assert.NoError(t, err)
		assert.True(t, gock.IsDone())
		assert.True(t, json.Valid(out))

- Add internal/api/blast/client.go with BaseURL constant
- Update all commands to use blast.BaseURL instead of hardcoded URLs:
  - get_match.go
  - get_matches.go
  - get_brackets.go
  - list_tournaments.go

This improves maintainability by centralizing the API base URL,
making it easier to update if the API endpoint ever changes.
@mgranderath
mgranderath merged commit 8b682f0 into main Feb 1, 2026
2 checks passed
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.

1 participant