Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/run_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,18 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-mojo
- name: Run example binaries (with retry)
- name: Build example binaries (with retry)
run: |
for attempt in 1 2 3; do
echo "=== debug attempt $attempt ==="
if pixi run debug; then
echo "=== debug passed on attempt $attempt ==="
echo "=== build attempt $attempt ==="
if pixi run build; then
echo "=== build passed on attempt $attempt ==="
break
fi
if [ "$attempt" -eq 3 ]; then
echo "=== debug failed after 3 attempts ==="
echo "=== build failed after 3 attempts ==="
exit 1
fi
echo "=== debug run crashed, retrying in 5s... ==="
echo "=== build run crashed, retrying in 5s... ==="
sleep 5
done
19 changes: 18 additions & 1 deletion docs/argmojo_overall_planning.md
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,10 @@ if result.subcommand == "search":

Some features shipped in v0.3.0, others completed in the unreleased update branch. Remaining items may be deferred to v0.4+.

Note that this phase is long-term polish and enhancement. If I find any other important or interesting features during development, I may add them here as well.

On the contrary, Phase 6 and Phase 7 are more about specific topics (e.g., CJK, declarative API, auto dispatch...) that require some dedicated design and implementation work. There might be standalone planning documents for these topics.

#### Pre-requisite refactor

Before adding Phase 5 features, further decompose `parse_arguments()` for readability and maintainability:
Expand Down Expand Up @@ -581,7 +585,8 @@ Before adding Phase 5 features, further decompose `parse_arguments()` for readab
- [x] **`NO_COLOR` env variable** — honour the [no-color.org](https://no-color.org/) standard: if env `NO_COLOR` is set (any value, including empty), suppress all ANSI colour output; lower priority than explicit `.color(False)` API call (PR #9)
- [x] **Value-name wrapping control** — `.value_name[wrapped: Bool = True]("NAME")` displays custom value names in `<NAME>` by default (matching clap/cargo/pixi/git convention); pass `False` for bare display (PR #17)
- [ ] **Extend `implies()`** - support value-taking options with a default value, e.g., `cmd.implies("debug", "output", "debug.log")` — when `--debug` is set, auto-set `--output` to `"debug.log"`. Currently `implies()` only supports flag/count targets (same as cobra in Go). Revisit when there is a concrete use case.
- [ ] **80-character help formatting** — wrap help descriptions at 80 columns with proper indentation (no major library does this by default; users typically pipe through `less` or rely on terminal wrapping)
- [x] **80-character help formatting** — wrap help descriptions at 80 columns with proper indentation (no major library does this by default; users typically pipe through `less` or rely on terminal wrapping)
- [ ] **Comptime string concatenation** — 將 String 的拼接 comptime 化,避免在運行時進行多次拼接(例如錯誤消息、幫助文本等),提升性能。

#### Explicitly Out of Scope in This Phase

Expand Down Expand Up @@ -618,6 +623,18 @@ ArgMojo's differentiating features — no other CLI library addresses CJK-specif

**References:** POSIX `wcwidth(3)`, Python `unicodedata.east_asian_width()`, Rust `unicode-width` crate.

##### CJK-aware word wrapping (TODO)

The current `_wrap_text_at` and `_wrap_description` helpers only split on ASCII spaces. This means:

- CJK text without spaces (e.g. continuous Chinese/Japanese) will never be broken and may exceed the 80-column width.
- Unicode whitespace characters (e.g. `U+3000` ideographic space, `U+2003` em space) are not recognized as split points.

Improvements needed:

- [ ] Split on all Unicode whitespace (not just ASCII space)
- [ ] Add fallback to break long CJK tokens by codepoint/display-width when a single token exceeds the target width

#### 6.2 Full-width → half-width auto-correction ✓

**Problem:** CJK users frequently forget to switch input methods, typing full-width ASCII:
Expand Down
9 changes: 6 additions & 3 deletions examples/yu.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,16 @@ def main() raises:
)

app.add_argument(
Argument("漢字", help="要查詢的漢字(可以輸入多個漢字)").positional().required()
Argument("漢字", help="要查詢的漢字\n(可以輸入多個漢字)").positional().required()
)
app.add_argument(
Argument("joy", help="使用卿雲編碼(預設為靈明)").long["joy"]().short["j"]().flag()
Argument("joy", help="使用卿雲編碼\n(預設為靈明)")
.long["joy"]()
.short["j"]()
.flag()
)
app.add_argument(
Argument("star", help="使用星陳編碼(預設為靈明)")
Argument("star", help="使用星陳編碼\n(預設為靈明)")
.long["star"]()
.short["s"]()
.flag()
Expand Down
Loading
Loading