Skip to content

print table when a url parsed - #5

Merged
omarkurt merged 1 commit into
mainfrom
feature/update-parsing-output
Jun 12, 2025
Merged

print table when a url parsed#5
omarkurt merged 1 commit into
mainfrom
feature/update-parsing-output

Conversation

@recepgunes1

@recepgunes1 recepgunes1 commented Jun 7, 2025

Copy link
Copy Markdown
Member

When I was working with long URLs, the current output system wasn't user-friendly, so I decided to print the output as a table.

Summary by CodeRabbit

  • New Features
    • Output for extracted URL components is now displayed in a formatted table for improved readability.
  • Improvements
    • Query parameters are presented in a separate table, making them easier to review.
    • Empty or missing URL components are now clearly indicated as "N/A" in the output.

@coderabbitai

coderabbitai Bot commented Jun 7, 2025

Copy link
Copy Markdown

Walkthrough

The changes introduce the go-pretty/table library and supporting dependencies to format URL extraction output as tables instead of plain text. The extractUrl function in the CLI now outputs parsed URL components and query parameters in tabular form. A utility function, StringOrDefault, is also added to handle empty string values.

Changes

File(s) Change Summary
go.mod Added go-pretty/table and related dependencies; upgraded golang.org/x/sys.
internal/cli/parse.go Refactored extractUrl to use table output for URL components and query parameters.
internal/utils/string.go Added StringOrDefault utility function for default string handling.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant Utils
    participant go-pretty/table

    User->>CLI: Invoke extractUrl with URL
    CLI->>Utils: StringOrDefault(component)
    Utils-->>CLI: Return trimmed or default string
    CLI->>go-pretty/table: Add rows for URL components
    CLI->>go-pretty/table: Add rows for query parameters
    go-pretty/table-->>CLI: Render tables
    CLI-->>User: Output formatted tables
Loading

Poem

In the warren where URLs once sprawled,
Now tables stand, neat and enthralled.
With pretty rows and columns bright,
Each fragment shines in tidy light.
A helper checks if strings are bare,
And fills the gaps with rabbit care.
Hooray for tables—output flair!

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@recepgunes1
recepgunes1 requested review from atiilla and omarkurt June 7, 2025 21:08

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
internal/cli/parse.go (1)

108-108: Fix the query parameters count message format.

The format string has grammatical and format specifier issues.

-			tbl.AppendRow(table.Row{"Query Params", fmt.Sprintf("%v value", len(queryParams))})
+			tbl.AppendRow(table.Row{"Query Params", fmt.Sprintf("%d values", len(queryParams))})
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d123da2 and caa3f17.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (3)
  • go.mod (1 hunks)
  • internal/cli/parse.go (2 hunks)
  • internal/utils/string.go (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
internal/cli/parse.go (2)
internal/utils/url.go (1)
  • CreateURL (7-16)
internal/utils/string.go (1)
  • StringOrDefault (5-10)
🔇 Additional comments (5)
go.mod (2)

7-7: LGTM! New dependency added for table formatting.

The addition of go-pretty library aligns with the PR objective to format URL parsing output as tables.


15-19:

Details

❌ Incorrect review comment

Verify dependency versions for security and compatibility.

The indirect dependencies and version upgrades look appropriate, but it's worth verifying these are the latest secure versions.


🏁 Script executed:

#!/bin/bash
# Check for latest versions and security advisories for the new dependencies
echo "Checking go-pretty library:"
curl -s "https://api.github.com/repos/jedib0t/go-pretty/releases/latest" | jq '.tag_name'

echo "Checking for Go security advisories:"
go list -m -json github.com/jedib0t/go-pretty/v6 | jq '.Version'

Length of output: 492


Action Required: Ignore go-pretty check and verify the actual indirect dependencies

The original comment’s verification script targets github.com/jedib0t/go-pretty, which isn’t introduced in lines 15–19 of your go.mod. Instead, please confirm that the following indirect modules are at their latest secure versions by running from your project root (where go.mod lives):

• github.com/mattn/go-runewidth v0.0.16
• github.com/rivo/uniseg v0.4.7
• github.com/spf13/pflag v1.0.6
• golang.org/x/sys v0.30.0
• golang.org/x/text v0.22.0

Example commands:

go list -m -versions github.com/mattn/go-runewidth
go list -m -versions github.com/rivo/uniseg
go list -m -versions github.com/spf13/pflag
go list -m -versions golang.org/x/sys
go list -m -versions golang.org/x/text

Likely an incorrect or invalid review comment.

internal/utils/string.go (1)

5-10: LGTM! Well-designed utility function.

The function correctly handles empty and whitespace-only strings with a meaningful default. The implementation is clean and follows the single responsibility principle.

internal/cli/parse.go (2)

56-64: LGTM! Well-structured table setup.

The table initialization with proper styling and headers is well-implemented. Using separate tables for main components and query parameters provides clear separation of concerns.


73-127: LGTM! Consistent use of StringOrDefault and proper table rendering.

The refactored output logic correctly uses the utility function for handling empty values and properly renders both tables. The conditional rendering of the query table when it has content is a nice touch.

@omarkurt
omarkurt merged commit 33559d5 into main Jun 12, 2025
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.

4 participants