

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# DLT CLI
<a name="dlt-cli"></a>

DLT CLI 可讓您直接從終端機與 AWS REST API 上的分散式負載測試互動。它啟用載入測試的指令碼自動化，可讓您列出、檢查和啟動測試案例，並在可重複的工作流程中查詢執行結果。

CLI 以與 DLT Web 主控台相同的 IAM 授權 API Gateway 為目標，因此瀏覽器型界面中可用的任何操作也可以使用相同的基礎 API 和許可模型從命令列執行。

CLI 原始程式碼和完整文件會在 `source/cli`目錄下存在於解決方案的 GitHub 儲存庫中。若要尋找它，請導覽至 [AWS 儲存庫上的分散式負載測試](https://github.com/aws-solutions/distributed-load-testing-on-aws)，然後開啟 `source/cli`。該目錄中`README.md`的 是安裝、組態、身分驗證和完整命令參考的授權參考。

## 關鍵功能
<a name="dlt-cli-capabilities"></a>


| 命令群組 | 說明 | 
| --- | --- | 
|  `configure`  | 以互動方式或匯入 `aws-exports.json` 檔案，使用 DLT 堆疊設定來設定 CLI。 | 
|  `login`  | 使用 DLT 服務進行驗證，並取得呼叫 API 所需的登入資料。 | 
|  `logout`  | 從本機電腦移除儲存的登入資料。 | 
|  `token`  | 檢查和輸出身分驗證字符和憑證過期狀態。 | 
|  `scenarios`  | 列出、檢視詳細資訊，並開始 （重新執行） 現有的測試案例。 | 
|  `runs`  | 查詢測試執行結果、檢視執行詳細資訊、與基準進行比較，以及下載執行成品。 | 

CLI 支援三種身分驗證模式：瀏覽器型登入 （透過 Cognito 託管 UI 的 PKCE 流程）、無周邊 SRP （安全遠端密碼） 身分驗證，以及直接 IAM 憑證身分驗證。如需每個模式的完整設定詳細資訊，請參閱 [GitHub 儲存庫](https://github.com/aws-solutions/distributed-load-testing-on-aws)`README.md``source/cli`目錄中的 。

## 安裝和詳細參考
<a name="dlt-cli-reference"></a>

CLI 以可攜式 Node.js 套件的形式分佈，可直接執行，或者您可以使用 儲存庫從來源建置。若要開始使用，請導覽至 GitHub [上的 AWS 儲存庫上的分散式負載測試](https://github.com/aws-solutions/distributed-load-testing-on-aws)，然後開啟 `source/cli`目錄。該目錄中`README.md`的檔案包含：
+ 安裝指示 （可攜式套件和 build-from-source)
+ 所有三種身分驗證模式的組態和身分驗證設定
+ 使用範例的完整命令參考

## 快速入門
<a name="dlt-cli-quick-start"></a>

**注意**  
此快速入門假設已部署 DLT 堆疊。

### 選項 1：可攜式套件 （建議）
<a name="option-1-portable-bundle-recommended"></a>

最快速的入門方法是可攜式套件。這不需要複製儲存庫或任何建置步驟：

```
# Download the portable bundle
curl -sLo /usr/local/bin/dlt \
  https://raw.githubusercontent.com/aws-solutions/distributed-load-testing-on-aws/main/deployment/cli/dlt-cli.mjs

# Make it executable
chmod +x /usr/local/bin/dlt

# Point the CLI at your deployed DLT stack
dlt configure

# Authenticate with the DLT service
dlt login

# Run a command (for example, list test scenarios)
dlt scenarios list
```

### 選項 2：從來源建置
<a name="option-2-build-from-source"></a>

如果您偏好從來源建置 ，請先複製[儲存庫](https://github.com/aws-solutions/distributed-load-testing-on-aws)。專案使用 npm 工作區，因此請從儲存庫根目錄執行下列命令：

```
# Install all workspace dependencies
npm install

# Build the CLI
npm run build -w source/cli

# Link the dlt command into your PATH
npm link -w source/cli

# Point the CLI at your deployed DLT stack
dlt configure

# Authenticate with the DLT service
dlt login

# Run a command (for example, list test scenarios)
dlt scenarios list
```