lip config
讀寫設定。
概要
text
lip config get <KEY> [--workspace] [--json] [-h | --help]
lip config set <KEY> <VALUE> [--workspace] [-h | --help]
lip config list [--workspace] [--json] [-h | --help]
lip config delete <KEY> [--workspace] [-h | --help]說明
config 組的命令讀寫某一個作用域的設定:
| 作用域 | 檔案 | 鍵 |
|---|---|---|
| 使用者(預設) | 設定目錄中的 config.toml | github_proxy、language |
工作區(帶 --workspace) | 目前目錄中的 .lip/config.toml | restart |
設定說明了每個鍵及其取值。
<KEY> 必須是所選作用域的鍵。不是的話,命令失敗。
| 命令 | 作用 |
|---|---|
lip config get <KEY> | 輸出 <KEY> 的值,或說明它沒有值。不做任何變更。 |
lip config set <KEY> <VALUE> | 把 <KEY> 設為 <VALUE>。<VALUE> 不是該鍵接受的值時,命令失敗,不做任何變更。 |
lip config list | 輸出該作用域的每個鍵及其值。不做任何變更。 |
lip config delete <KEY> | 從檔案中移除 <KEY>,使它取預設值;沒有預設值時,它就沒有值。 |
<VALUE> 可以為空,在 shell 中寫作 "":lip config set github_proxy ""。這個空值是作為操作數給出的;選項的值則永遠不能為空。
set 和 delete 會重寫該作用域的整個檔案:format = 4,加上值不同於預設值的鍵。帶 --workspace 時,.lip 不存在就建立它。它們不取得工作區鎖,所以伺服器執行時也能使用。
選項
| 選項 | 說明 |
|---|---|
--workspace | 使用工作區設定,即目前目錄中的 .lip/config.toml,而不是使用者設定。 |
--json | 用於 get 和 list:以 JSON 輸出結果。 |
-h、--help | 輸出幫助並結束。 |
輸出
get 和 list 把結果寫到標準輸出。set 和 delete 沒有結果;它們的最後一行是寫到標準錯誤的消息。
不帶 --json 時,結果是一張給人看的表。沒有值的鍵顯示 (not set),空值顯示 (empty):
text
┌──────────────┬───────────┐
│ Key │ Value │
├──────────────┼───────────┤
│ github_proxy │ (not set) │
│ language │ zh-Hans │
└──────────────┴───────────┘帶 --json 時:
| 命令 | 結果 |
|---|---|
lip config get <KEY> --json | 值,作為 JSON 字串;鍵沒有值時為 null。 |
lip config list --json | 一個 JSON 物件,以同樣的方式把該作用域的每個鍵映射到它的值。 |
shell
lip config get restart --workspace --jsonjson
"never"shell
lip config list --jsonjson
{
"github_proxy": null,
"language": "zh-Hans"
}結束狀態
| 結束代碼 | 含義 |
|---|---|
0 | 命令成功。對沒有值的鍵執行 get 也算成功。 |
非 0 | 用法錯誤、鍵不屬於該作用域、值不被該鍵接受,或檔案無法寫入。 |
示例
通過代理伺服器傳送 GitHub 請求,之後再恢復為詢問:
shell
lip config set github_proxy https://proxy.example.com/
lip config delete github_proxy直接連線 GitHub,並讓介面不再詢問:
shell
lip config set github_proxy ""設定介面的語言:
shell
lip config set language zh-Hans讓這個工作區的伺服器在當機時重新啟動:
shell
lip config set restart on-failure --workspace