Rush Stack商店部落格活動
跳至主要內容

Everyday Heft 命令

Hello World」教學介紹了 heft buildheft test 命令列動作。在本部分,我們將簡要說明幾個特別有用的日常命令。有關動作和參數的完整清單,請參閱 Heft 命令列 參考。

調查問題

如果你正在診斷 Heft build 的問題,有幾個有用的參數要知道

  • --verbose:例如,你可以執行 heft build --verbose 來查看關於如何呼叫任務的更多詳細資訊,而不是 heft build
  • --debug:若要取得更多詳細資訊,你可以執行 heft --debug build,查看呼叫堆疊和額外的追蹤資訊。請注意,--debug 是全域參數,因此必須置於 build 動作名稱之前。

執行多個任意階段

你在 heft.config 定義的每個階段都會產生一組命令列動作,用來呼叫該階段及其相依性 (使用 phaseDependencies 宣告)。「heft run」命令允許你選擇要執行的任意階段

usage: heft run [-h] [-t PHASE] [-T PHASE] [-o PHASE] ...

Run a provided selection of Heft phases.

Positional arguments:
"..." Scoped parameters. Must be prefixed with "--", ex.
"-- --scopedParameter foo --scopedFlag". For more
information on available scoped parameters, use "--
--help".

Optional arguments:
-h, --help Show this help message and exit.

Optional scoping arguments:
-t PHASE, --to PHASE The phase to run to, including all transitive
dependencies.
-T PHASE, --to-except PHASE
The phase to run to (but not include), including all
transitive dependencies.
-o PHASE, --only PHASE
The phase to run.

假設你的 test 階段相依於 build。執行 heft test 通常會同時執行兩個階段。若要呼叫*只有*test 階段,你可以使用 heft run --only test

請注意,無法單獨執行任務。階段是選擇 Heft 作業的最小單位。