Skip to content

Releases: superyngo/cate

v0.4.2

01 Dec 02:11

Choose a tag to compare

feat: v0.4.2 - 移除管道偵測,簡化顏色控制邏輯

主要變更

移除自動顏色控制功能

  • 移除 ColorMode 枚舉(Auto/Always/Never)
  • 移除 is_redirected_to_file() 函數(TTY 和管道檢測)
  • 移除 --color 參數
  • 簡化語法高亮控制:現在只透過 --no-highlight 參數控制

行為變更

之前 (v0.4.1)

  • --color auto(預設):終端和管道有顏色,文件重定向無顏色
  • --color always:強制輸出顏色
  • --color never:禁用顏色

現在 (v0.4.2)

  • 預設:始終啟用語法高亮(包括管道和文件重定向)
  • --no-highlight:完全關閉語法高亮

優點

  • ✅ 更簡單直觀的使用體驗
  • ✅ 移除複雜的 TTY 檢測邏輯(Unix fstat, Windows IsTerminal)
  • ✅ 減少程式碼複雜度
  • ✅ 用戶可以自行決定何時需要語法高亮

文檔更新

  • 更新 README.md 移除 --color 參數說明
  • 更新 help 信息
  • 移除過時的範例和說明

🤖 Generated with Claude Code

Co-Authored-By: Claude [email protected]


📦 下載 / Downloads

請從下方選擇適合您系統的版本下載。
Please download the appropriate version for your system from below.

🔒 檔案校驗 / File Verification

使用 SHA256SUMS 檔案驗證下載的檔案完整性。
Use the SHA256SUMS file to verify the integrity of downloaded files.


📝 自動生成的變更日誌 / Auto-generated Changelog

Full Changelog: v0.4.1...v0.4.2

v0.4.1

28 Nov 08:13

Choose a tag to compare

feat: v0.4.1 - 行號格式優化、管道顏色保留、shell 配置文件支援

主要變更

1. 行號格式優化

  • 移除行號右對齊縮排,從 {:>6} 改為 {}
  • 使輸出更緊湊,行號與內容之間只保留單個空格
  • 修改位置:src/printer.rs:77, 96

2. 管道顏色保留功能

  • 改進 TTY 檢測邏輯:區分管道和文件重定向
  • 新增 is_redirected_to_file() 函數使用 libc::fstat 檢測輸出類型
  • 行為變更:
    • 終端輸出:保留顏色 ✅
    • 管道傳輸 (|):保留顏色 ✅ (新)
    • 文件重定向 (>):禁用顏色 ❌
  • 新增依賴:libc = "0.2" (Unix 平台)
  • 修改位置:src/main.rs:31-59

3. Shell 配置文件自動識別

  • 新增 shell 配置文件自動使用 bash 語法高亮
  • 支援的文件名:
    • Bash: .bashrc, .bash_profile, .bash_login, .bash_logout, bashrc, bash_profile
    • Zsh: .zshrc, .zprofile, .zshenv, .zlogin, .zlogout
    • 通用: .profile
  • 修改位置:src/highlighter.rs:125-140

技術細節

Unix 平台文件類型檢測
使用 libc::fstatS_IFMT 掩碼檢測文件描述符類型:

  • S_ISREG: 普通文件 → 禁用顏色
  • S_ISFIFO: 管道 → 保留顏色
  • S_ISCHR: 字符設備(終端) → 保留顏色

Windows 平台
保守策略:非終端輸出一律禁用顏色(管道和文件都禁用)

版本資訊

  • 版本:0.4.0 → 0.4.1
  • 日期:2025-11-28

🤖 Generated with Claude Code

Co-Authored-By: Claude [email protected]


📦 下載 / Downloads

請從下方選擇適合您系統的版本下載。
Please download the appropriate version for your system from below.

🔒 檔案校驗 / File Verification

使用 SHA256SUMS 檔案驗證下載的檔案完整性。
Use the SHA256SUMS file to verify the integrity of downloaded files.


📝 自動生成的變更日誌 / Auto-generated Changelog

Full Changelog: v0.4.0...v0.4.1

v0.4.0

28 Nov 07:28

Choose a tag to compare

feat: 添加 TTY 檢測和 --color 參數

🎨 新功能:智能顏色輸出控制

1. 自動 TTY 檢測

  • 使用 std::io::IsTerminal 檢測輸出目標
  • 終端輸出:自動啟用語法高亮
  • 重定向到文件:自動禁用顏色碼
  • 避免污染重定向的文件

2. --color 參數

新增顏色控制選項:

  • --color auto(默認):根據 TTY 自動決定
  • --color always:強制輸出顏色(適用於 less -R 等支援顏色的 pager)
  • --color never:完全禁用顏色輸出

3. 優先級邏輯

--no-highlight > --color > TTY 自動檢測

📝 使用範例

# 終端顯示:有顏色
cate file.rs

# 重定向到文件:自動無顏色
cate file.rs > output.txt

# 強制顏色給 pager
cate file.rs --color always | less -R

# 完全禁用顏色
cate file.rs --color never

🔧 技術實現

  • 添加 ColorMode 枚舉(Auto/Always/Never)
  • 使用 std::io::IsTerminal trait
  • 更新 help 訊息和文檔
  • 添加完整的測試覆蓋

📚 文檔更新

  • README.md:添加顏色控制說明和範例
  • 更新 Features 列表
  • 添加性能說明中的 TTY 檢測部分

🤖 Generated with Claude Code

Co-Authored-By: Claude [email protected]


📦 下載 / Downloads

請從下方選擇適合您系統的版本下載。
Please download the appropriate version for your system from below.

🔒 檔案校驗 / File Verification

使用 SHA256SUMS 檔案驗證下載的檔案完整性。
Use the SHA256SUMS file to verify the integrity of downloaded files.


📝 自動生成的變更日誌 / Auto-generated Changelog

Full Changelog: v0.3.1...v0.4.0

v0.3.1

26 Nov 07:45

Choose a tag to compare

chore: bump version to 0.3.1


📦 下載 / Downloads

請從下方選擇適合您系統的版本下載。
Please download the appropriate version for your system from below.

🔒 檔案校驗 / File Verification

使用 SHA256SUMS 檔案驗證下載的檔案完整性。
Use the SHA256SUMS file to verify the integrity of downloaded files.


📝 自動生成的變更日誌 / Auto-generated Changelog

Full Changelog: v0.3.0...v0.3.1

v0.1.1

18 Nov 05:06

Choose a tag to compare

修復非 Windows 平台的構建錯誤

將 Build step 分為兩個步驟以避免空環境變量錯誤:

  • Build (Windows): 包含所有溫和編譯參數
  • Build (Linux and macOS): 使用標準設定

修復錯誤: CARGO_PROFILE_RELEASE_OPT_LEVEL 空字符串導致的構建失敗

🤖 Generated with Claude Code

Co-Authored-By: Claude [email protected]


📦 下載 / Downloads

請從下方選擇適合您系統的版本下載。
Please download the appropriate version for your system from below.

🔒 檔案校驗 / File Verification

使用 SHA256SUMS 檔案驗證下載的檔案完整性。
Use the SHA256SUMS file to verify the integrity of downloaded files.


📝 自動生成的變更日誌 / Auto-generated Changelog

Full Changelog: v0.1.0...v0.1.1

v0.1.0

17 Nov 05:36

Choose a tag to compare

Initial commit - cate v0.1.0

A lightweight CLI tool to display file contents with encoding support.

Features:

  • Multi-encoding support (UTF-8, GBK, Big5, Shift-JIS, etc.)
  • Smart encoding detection (UTF-8/BOM > User specified > System encoding)
  • Line number display (-n flag)
  • Debug mode for encoding detection
  • Stdin support
  • Cross-platform CI/CD workflow

🤖 Generated with Claude Code


📦 下載 / Downloads

請從下方選擇適合您系統的版本下載。
Please download the appropriate version for your system from below.

🔒 檔案校驗 / File Verification

使用 SHA256SUMS 檔案驗證下載的檔案完整性。
Use the SHA256SUMS file to verify the integrity of downloaded files.


📝 自動生成的變更日誌 / Auto-generated Changelog

Full Changelog: https://github.com/superyngo/cate/commits/v0.1.0