Skip to content

Update tuzuru list command with swift-wcwidth#18

Merged
ainame merged 2 commits intomainfrom
ai/wcwidth-list
Sep 13, 2025
Merged

Update tuzuru list command with swift-wcwidth#18
ainame merged 2 commits intomainfrom
ai/wcwidth-list

Conversation

@ainame
Copy link
Owner

@ainame ainame commented Sep 13, 2025

Previously, tuzuru list command was implemented with compromised solution outputting data in CSV format, which works fine for debug purpose. But I'd love to put those data in a table with border to make it readable.

I needed to investigate how to do it and learn wcwidth, ICU, Unicode's EastAsianWidth.txt, or some equivalent OSS in other languages. As a result, I created https://github.com/ainame/swift-wcwidth based on my research.

tuzuru list now use it internally and can draw perfect table even when CJK chars, Thai, Arabic, or emojis appear in the output.

Screenshot 2025-09-13 at 17 20 59

Copilot AI review requested due to automatic review settings September 13, 2025 16:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Updates the tuzuru list command from CSV output to a formatted table with proper Unicode character width handling using the swift-wcwidth library.

  • Replaces CSV output with a bordered table format
  • Adds Year and Category columns to display additional metadata
  • Implements proper Unicode character width calculation for accurate column alignment

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
Sources/Command/ListCommand.swift Transforms CSV output to table format with new columns and Unicode-aware text handling
Package.swift Adds swift-wcwidth dependency for proper character width calculation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ainame ainame marked this pull request as ready for review September 13, 2025 16:56
Copilot AI review requested due to automatic review settings September 13, 2025 16:56
@ainame ainame enabled auto-merge (squash) September 13, 2025 16:56
@ainame ainame disabled auto-merge September 13, 2025 16:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 6 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +79 to +89
if wcwidth(string) <= maxLength {
return string
}
return String(string.prefix(maxLength - 3)) + "..."

var truncated = ""
var currentWidth = 0
let ellipsis = "..."
let ellipsisWidth = wcwidth(ellipsis)
let targetWidth = maxLength - ellipsisWidth

for char in string {
let charWidth = wcwidth(char)
Copy link

Copilot AI Sep 13, 2025

Choose a reason for hiding this comment

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

The wcwidth function should be called on the wcwidth instance, not as a standalone function. Use wcwidth.width(of: string) instead of wcwidth(string).

Copilot uses AI. Check for mistakes.
@ainame ainame enabled auto-merge (squash) September 13, 2025 16:58
@ainame ainame merged commit e05a9ad into main Sep 13, 2025
1 check passed
@ainame ainame deleted the ai/wcwidth-list branch September 13, 2025 17:00
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.

2 participants