print table when a url parsed - #5
Conversation
WalkthroughThe changes introduce the Changes
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
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
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
⛔ Files ignored due to path filters (1)
go.sumis 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-prettylibrary 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 yourgo.mod. Instead, please confirm that the following indirect modules are at their latest secure versions by running from your project root (wherego.modlives):• 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.0Example 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/textLikely 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.
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