Skip to content

Commit 64d4ec5

Browse files
authored
feat: 添加智能文本自动换行功能 (#18)
- 支持智能文本自动换行,确保AI生成的提交消息和分支名在终端中正确显示 - 实现代码块保护、链接保留、行内代码处理等高级文本处理功能 - 添加CLI参数 --no-wrap 和 --wrap-width 控制文本换行行为 - 支持配置文件控制文本换行行为 - 更新文档说明新功能的使用方法 Signed-off-by: jinlong <jinlong@tencent.com>
1 parent 5eaf195 commit 64d4ec5

File tree

13 files changed

+1257
-9
lines changed

13 files changed

+1257
-9
lines changed

Cargo.lock

Lines changed: 22 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "fastcommit"
3-
version = "0.4.0"
3+
version = "0.5.0"
44
description = "AI-based command line tool to quickly generate standardized commit messages."
55
edition = "2021"
66
authors = ["longjin <fslongjin@vip.qq.com>"]
@@ -25,3 +25,5 @@ tokio = { version = "1.43.0", features = ["full"] }
2525
rand = "0.8.5"
2626
indicatif = "0.17.8"
2727
toml = "0.8.20"
28+
unicode-width = "0.2.0"
29+
terminal_size = "0.4.0"

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ You can install `fastcommit` using the following method:
1010

1111
```bash
1212
# Install using cargo
13-
cargo install --git https://github.com/fslongjin/fastcommit --tag v0.4.0
13+
cargo install --git https://github.com/fslongjin/fastcommit --tag v0.5.0
1414
```
1515

16+
1617
## Usage
1718

1819
### Basic Usage
@@ -35,6 +36,8 @@ NOTE: All common config can be configured via `~/.fastcommit/config.toml`
3536
- `-v, --verbosity <VERBOSITY>`: Set the detail level of the commit message. Acceptable values are `verbose` (detailed), `normal`, or `quiet` (concise). The default is `quiet`.
3637
- `-p, --prompt <PROMPT>`: Additional prompt to help AI understand the commit context.
3738
- `-r, --range <RANGE>`: Specify diff range for generating commit message (e.g. HEAD~1, abc123..def456).
39+
- `--no-wrap`: Disable text wrapping for long lines.
40+
- `--wrap-width <WIDTH>`: Set custom line width for text wrapping (default: config file setting or 80).
3841
- `-h, --help`: Print help information.
3942
- `-V, --version`: Print version information.
4043

@@ -86,6 +89,19 @@ NOTE: All common config can be configured via `~/.fastcommit/config.toml`
8689
fastcommit -r abc123..def456
8790
```
8891

92+
8. Control text wrapping behavior:
93+
94+
```bash
95+
# Disable text wrapping
96+
fastcommit --no-wrap
97+
98+
# Set custom line width
99+
fastcommit --wrap-width 60
100+
101+
# Combine with other options
102+
fastcommit -b -m --wrap-width 100
103+
```
104+
89105
## Contributing
90106

91107
Contributions of code or suggestions are welcome! Please read the [Contributing Guide](CONTRIBUTING.md) first.

README_CN.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
```bash
1010
# 使用 cargo 安装
11-
cargo install --git https://github.com/fslongjin/fastcommit --tag v0.4.0
11+
cargo install --git https://github.com/fslongjin/fastcommit --tag v0.5.0
1212
```
1313

1414
## 使用
@@ -33,6 +33,8 @@ NOTE: All common config can be configured via `~/.fastcommit/config.toml`
3333
- `-v, --verbosity <VERBOSITY>`: 设置提交信息的详细级别。可选值为 `verbose`(详细)、`normal`(正常)或 `quiet`(简洁)。 默认为 `quiet`
3434
- `-p, --prompt <PROMPT>`: 额外的提示信息,帮助 AI 理解提交上下文。
3535
- `-r, --range <RANGE>`: 指定差异范围以生成提交信息(例如:HEAD~1, abc123..def456)。
36+
- `--no-wrap`: 禁用长行文本换行。
37+
- `--wrap-width <WIDTH>`: 设置文本换行的自定义行宽度(默认:配置文件设置或 80)。
3638
- `-h, --help`: 打印帮助信息。
3739
- `-V, --version`: 打印版本信息。
3840

@@ -84,6 +86,19 @@ NOTE: All common config can be configured via `~/.fastcommit/config.toml`
8486
fastcommit -r abc123..def456
8587
```
8688

89+
8. 控制文本换行行为:
90+
91+
```bash
92+
# 禁用文本换行
93+
fastcommit --no-wrap
94+
95+
# 设置自定义行宽度
96+
fastcommit --wrap-width 60
97+
98+
# 与其他选项组合使用
99+
fastcommit -b -m --wrap-width 100
100+
```
101+
87102
## 贡献
88103

89104
欢迎贡献代码或提出建议!请先阅读 [贡献指南](CONTRIBUTING.md)

0 commit comments

Comments
 (0)