Skip to content

Commit

Permalink
20240522 update
Browse files Browse the repository at this point in the history
  • Loading branch information
neko0xff committed May 21, 2024
1 parent a96bffb commit a05989e
Show file tree
Hide file tree
Showing 42 changed files with 11 additions and 19 deletions.
Empty file modified src/README.md
100644 → 100755
Empty file.
Empty file modified src/SUMMARY.md
100644 → 100755
Empty file.
Empty file modified src/in-depth/README.md
100644 → 100755
Empty file.
Empty file modified src/in-depth/config-files.md
100644 → 100755
Empty file.
26 changes: 9 additions & 17 deletions src/in-depth/docs.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# 為你的 CLI 程式產生文件

CLI 的文件 通常包括指令中的 `--help` 部分和一個手冊(`man`)頁面。
CLI 程式的文件 通常會包括指令中的 `--help` 部分和一個手冊(`man`)頁面。

Both can be automatically generated
when using [`clap`](https://crates.io/crates/clap), via
[`clap_mangen`](https://crates.io/crates/clap_mangen) crate.

兩者都可以自動生成
使用 [`clap`](https://crates.io/crates/clap) 時,透過[`clap_mangen`](https://crates.io/crates/clap_mangen) 箱。
兩者都可以自動產生
當使用 [`clap`](https://crates.io/crates/clap) 時,
會透過 [`clap_mangen`](https://crates.io/crates/clap_mangen) crate。

```rust,ignore
#[derive(Parser)]
Expand All @@ -20,16 +17,11 @@ pub struct Head {
}
```

Secondly, you need to use a `build.rs`
to generate the manual file at compile time
from the definition of your app
in code.
其次,您需要使用 `build.rs`在編譯時,
請根據您的應用程式在程式碼中的定義而產生手冊文件。

There are a few things to keep in mind
(such as how you want to package your binary)
but for now
we simply put the `man` file
next to our `src` folder.
在這裡你要留意幾件事(例如如何打包你的程式),
但現在我們只是簡單地把 `man` 檔案放到我們的 `src` 同等級目錄。

```rust,ignore
use clap::CommandFactory;
Expand Down Expand Up @@ -57,4 +49,4 @@ in your project directory.

If you open that in `man`
you'll be able to admire your free documentation.
如果你在 `man` 中打開它,則你可閱讀
如果你在 `man` 中打開它,則你可閱讀文件
Empty file modified src/in-depth/exit-code.md
100644 → 100755
Empty file.
Empty file modified src/in-depth/human-communication.md
100644 → 100755
Empty file.
Empty file modified src/in-depth/machine-communication-stdin.rs
100644 → 100755
Empty file.
Empty file modified src/in-depth/machine-communication-wc.rs
100644 → 100755
Empty file.
Empty file modified src/in-depth/machine-communication.md
100644 → 100755
Empty file.
Empty file modified src/in-depth/machine-communication.rs
100644 → 100755
Empty file.
Empty file modified src/in-depth/signals-channels.rs
100644 → 100755
Empty file.
Empty file modified src/in-depth/signals-ctrlc.rs
100644 → 100755
Empty file.
Empty file modified src/in-depth/signals-hooked.rs
100644 → 100755
Empty file.
Empty file modified src/in-depth/signals.md
100644 → 100755
Empty file.
Empty file modified src/resources/README.md
100644 → 100755
Empty file.
Empty file modified src/special-content.css
100644 → 100755
Empty file.
Empty file modified src/tutorial/README.md
100644 → 100755
Empty file.
Empty file modified src/tutorial/cli-args-clap.rs
100644 → 100755
Empty file.
Empty file modified src/tutorial/cli-args-struct.rs
100644 → 100755
Empty file.
Empty file modified src/tutorial/cli-args-vars.rs
100644 → 100755
Empty file.
Empty file modified src/tutorial/cli-args.asciinema
100644 → 100755
Empty file.
Empty file modified src/tutorial/cli-args.md
100644 → 100755
Empty file.
Empty file modified src/tutorial/cli-args.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified src/tutorial/errors-custom.rs
100644 → 100755
Empty file.
Empty file modified src/tutorial/errors-exit.rs
100644 → 100755
Empty file.
Empty file modified src/tutorial/errors-impl.rs
100644 → 100755
Empty file.
Empty file modified src/tutorial/errors.md
100644 → 100755
Empty file.
Empty file modified src/tutorial/impl-draft-shortcut.rs
100644 → 100755
Empty file.
Empty file modified src/tutorial/impl-draft.md
100644 → 100755
Empty file.
Empty file modified src/tutorial/impl-draft.rs
100644 → 100755
Empty file.
Empty file modified src/tutorial/output-log.rs
100644 → 100755
Empty file.
Empty file modified src/tutorial/output-progressbar.rs
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion src/tutorial/output.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ writeln!(handle, "foo: {}", 42); // add `?` if you care about errors here
有些 CLI 程式的運作時間很長,
會花費幾分鐘甚至數小時。
如果你在編寫這種程式,
你可能想要向使用者展示,其程式正在正常運作中。
你可能需要向使用者展示,其程式正在正常運作中。
因此,你需要輸出有用的狀態更新訊息,
最好是使用易於使用的方式來進行輸出。

Expand Down
Empty file modified src/tutorial/packaging.md
100644 → 100755
Empty file.
Empty file modified src/tutorial/setup.asciinema
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion src/tutorial/setup.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
- `Cargo.toml` 裡包含了我們專案所有的中繼資料,包括我們使用依賴/外部函式庫列表。
- `src/main.rs` 是我們程式的二進制入口檔案(主程式)。

如果可以在`grrs`目錄下執行`cargo run`並得到一個Hello World,那你就已經準備好了。
如果可以在`grrs`目錄下執行`cargo run`並得到一個 `Hello, World!`,那你就已經準備好了。

## 它可能會是什麼樣子

Expand Down
Empty file modified src/tutorial/setup.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified src/tutorial/testing.md
100644 → 100755
Empty file.
Empty file modified src/tutorial/testing/Cargo.toml
100644 → 100755
Empty file.
Empty file modified src/tutorial/testing/src/main.rs
100644 → 100755
Empty file.
Empty file modified src/tutorial/testing/tests/cli.rs
100644 → 100755
Empty file.

0 comments on commit a05989e

Please sign in to comment.