Skip to content

Commit aeba151

Browse files
修正 Hook 音频示例 (#541)
1 parent 9cc7688 commit aeba151

2 files changed

Lines changed: 10 additions & 20 deletions

File tree

docs/05-mcpp-toml.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,9 +2186,6 @@ build_start = "echo build started"
21862186
build_failed = "notify-send 'build failed'"
21872187
build_finished = "notify-send 'build finished'"
21882188

2189-
# Runs alongside the build and is stopped when it ends.
2190-
during_build = { cmd = "mcpp-hooks-audioplayer bgm", loop = true }
2191-
21922189
# Optional; these are the defaults.
21932190
timeout_seconds = 10
21942191
enabled = true
@@ -2239,8 +2236,8 @@ build_start
22392236
└─ build fails → during_build closes → build_failed
22402237
```
22412238

2242-
`during_build` closes **before** the terminal hook, so a "build finished" sound
2243-
is not competing with the background music it replaces.
2239+
`during_build` closes **before** the terminal hook, so the two commands never
2240+
overlap.
22442241

22452242
`build_failed` and `build_finished` are mutually exclusive, and both are
22462243
reachable only after `build_start` has run. A project that cannot be *prepared*
@@ -2318,7 +2315,6 @@ than adding media handling to mcpp:
23182315

23192316
```toml
23202317
[hooks]
2321-
during_build = { cmd = "mcpp-hooks-audioplayer bgm", loop = true }
23222318
build_finished = "mcpp-hooks-audioplayer niulai-mm"
23232319
build_failed = "mcpp-hooks-audioplayer niulai-niulai"
23242320
side_effect = false
@@ -2327,11 +2323,10 @@ side_effect = false
23272323
deps = ["xim:mcpp-hooks-audioplayer@0.0.1"]
23282324
```
23292325

2330-
Background music for the length of the build, and a different sound for how it
2331-
ended. `side_effect = false` is written out rather than left to the default:
2332-
it is the value this manifest wants on its own terms — a missing audio device
2333-
should never fail a build — so it will still say so once the key has more than
2334-
one accepted value.
2326+
A different sound for a successful or failed build. `side_effect = false` is
2327+
written out rather than left to the default: it is the value this manifest
2328+
wants on its own terms — a missing audio device should never fail a build — so
2329+
it will still say so once the key has more than one accepted value.
23352330

23362331
## Appendix A. Schema Ownership Principle (admission criteria for new fields)
23372332

docs/zh/05-mcpp-toml.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1868,9 +1868,6 @@ build_start = "echo build started"
18681868
build_failed = "notify-send 'build failed'"
18691869
build_finished = "notify-send 'build finished'"
18701870

1871-
# 与构建并行,构建结束时被停止。
1872-
during_build = { cmd = "mcpp-hooks-audioplayer bgm", loop = true }
1873-
18741871
# 可选;以下是默认值。
18751872
timeout_seconds = 10
18761873
enabled = true
@@ -1916,8 +1913,7 @@ build_start
19161913
└─ 构建失败 → during_build 闭合 → build_failed
19171914
```
19181915

1919-
`during_build` 在终止 Hook **之前**闭合,这样"构建完成"的提示音不会和它要替换掉的
1920-
背景音乐撞在一起。
1916+
`during_build` 在终止 Hook **之前**闭合,因此两条命令不会重叠执行。
19211917

19221918
`build_failed``build_finished` 互斥,而且两者都只在 `build_start` 已经执行之后
19231919
才可达。项目**准备**阶段就失败的情况——manifest 非法、依赖无法解析、没有可用工具链
@@ -1976,7 +1972,6 @@ Hook 程序可以作为普通 xlings 依赖安装。例如,音频通知程序可
19761972

19771973
```toml
19781974
[hooks]
1979-
during_build = { cmd = "mcpp-hooks-audioplayer bgm", loop = true }
19801975
build_finished = "mcpp-hooks-audioplayer niulai-mm"
19811976
build_failed = "mcpp-hooks-audioplayer niulai-niulai"
19821977
side_effect = false
@@ -1985,9 +1980,9 @@ side_effect = false
19851980
deps = ["xim:mcpp-hooks-audioplayer@0.0.1"]
19861981
```
19871982

1988-
构建全程的背景音乐,加上一段区分结果的提示音`side_effect = false` 写出来而不是靠
1989-
默认值:它是这份 manifest 自己就想要的值——缺个音频设备不该让构建失败——所以等这个键
1990-
有了不止一个可接受的值之后,它仍然会这么写。
1983+
根据构建成功或失败播放不同提示音`side_effect = false` 写出来而不是靠默认值:它是
1984+
这份 manifest 自己就想要的值——缺个音频设备不该让构建失败——所以等这个键有了不止
1985+
一个可接受的值之后,它仍然会这么写。
19911986

19921987
## 附录 A. Schema 所有权原则(新字段准入标准)
19931988

0 commit comments

Comments
 (0)