{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/zh/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"CLI 概述","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"cli-概述","__idx":0},"children":["CLI 概述"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ml-cli"]}," 是 MoreLogin 本地 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["httpServer"]}," 的命令行界面。它将 CLI 参数转换为 HTTP 请求，并将它们转发到 MoreLogin 客户端公开的本地 API。"]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"概述","__idx":1},"children":["概述"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["它适合谁？"]}," ","DevOps 工程师、QA 自动化工程师以及喜欢在终端中工作或需要将 MoreLogin 集成到 CI/CD 管道（例如 GitHub Actions、Jenkins 或 shell 脚本）中的开发人员。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["它能做什么？"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["直接从终端调用MoreLogin本地API，无需编写HTTP请求代码。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["从一个统一的界面管理浏览器环境、代理、云手机和日程安排。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["使用稳定的 CLI 标志而不是手动构建 JSON 有效负载。"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["如何开始？"]}]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["阅读下面的",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["先决条件"]},"。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["下载并安装适合您平台的 CLI。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["检查",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/zh/cli/quick-start"},"children":["快速启动"]}," 以运行您的第一个命令。"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"先决条件","__idx":2},"children":["先决条件"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["在使用 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ml-cli"]}," 之前，请确保满足以下要求："]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["MoreLogin 桌面客户端"]}," 在同一台计算机上安装并运行"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["您有一个活跃的 MoreLogin 帐户，具有 ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["API 凭证"]},"（API ID + API 密钥）"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"下载安装","__idx":3},"children":["下载&安装"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["下载适合您平台的最新 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ml-cli"]}," 二进制文件："]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"平台"},"children":["平台"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"架构"},"children":["架构"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"链接"},"children":["链接"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Windows"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["x64"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://get.morelogin.com/client/prod/win/x64/2.6.1/ml-cli.exe"},"children":["下载"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["macOS"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["x64（Intel）"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://get.morelogin.com/client/prod/mac/x64/2.6.1/ml-cli"},"children":["下载"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["macOS"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["arm64（Apple Silicon）"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://get.morelogin.com/client/prod/mac/arm64/2.6.1/ml-cli"},"children":["下载"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Linux"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["x64"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://get.morelogin.com/client/prod/linux/x64/2.6.1/ml-cli"},"children":["下载"]}]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"windows","__idx":4},"children":["Windows"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["为 CLI 创建一个目录，例如 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["C:\\Program Files\\MoreLogin\\"]},"："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"powershell","header":{"controls":{"copy":{}}},"source":"New-Item -ItemType Directory -Force -Path \"C:\\Program Files\\MoreLogin\"\n","lang":"powershell"},"children":[]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["将下载的 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ml-cli.exe"]}," 移动到该目录中。"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["将目录添加到您的系统 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PATH"]},"："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"powershell","header":{"controls":{"copy":{}}},"source":"# Add to the current user's PATH permanently\n$currentPath = [Environment]::GetEnvironmentVariable(\"Path\", \"User\")\n[Environment]::SetEnvironmentVariable(\"Path\", \"$currentPath;C:\\Program Files\\MoreLogin\", \"User\")\n","lang":"powershell"},"children":[]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["重新启动终端"]},"（或打开一个新终端）以使更改生效。"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["核实："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"powershell","header":{"controls":{"copy":{}}},"source":"ml-cli --version\n","lang":"powershell"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"macos","__idx":5},"children":["macOS"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["使二进制可执行文件："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"chmod +x ml-cli\n","lang":"bash"},"children":[]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["将其移至 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PATH"]}," 中的目录："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"sudo mv ml-cli /usr/local/bin/\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["如果 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/usr/local/bin"]}," 不存在，请先创建：",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sudo mkdir -p /usr/local/bin"]}]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["在 macOS 上，下载的二进制文件可能会被 Gatekeeper 阻止。删除隔离属性："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"xattr -d com.apple.quarantine /usr/local/bin/ml-cli\n","lang":"bash"},"children":[]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["验证："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"ml-cli --version\n","lang":"bash"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"linux","__idx":6},"children":["Linux"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["使二进制可执行文件："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"chmod +x ml-cli\n","lang":"bash"},"children":[]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["将其移至 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PATH"]}," 中的目录："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"sudo mv ml-cli /usr/local/bin/\n","lang":"bash"},"children":[]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["验证："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"ml-cli --version\n","lang":"bash"},"children":[]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["安装后，请参阅",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/zh/cli/quick-start"},"children":["快速入门"]}," 连接到 MoreLogin 客户端并运行第一个命令。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"核心能力","__idx":7},"children":["核心能力"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["当前的 CLI 涵盖以下资源组："]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["服务状态和登录"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["通过 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["env"]}," 进行浏览器环境管理"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["通过 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cloudphone"]}," 进行云手机管理"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["通过 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["group"]}," 进行分组管理"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["通过 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["tag"]}," 进行标签管理"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["通过 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["proxy"]}," 进行代理管理"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["通过 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["schedule"]}," 进行云手机日程管理"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"请求模型","__idx":8},"children":["请求模型"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["CLI 支持两种输入方式："]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["显式标志，例如 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--env-id"]}," 或 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--group-name"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["通过 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--json-data"]}," 的原始 JSON"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["它们可以组合起来。合并规则为："]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--json-data"]}," 提供基本请求正文"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["显式 CLI 标志覆盖来自 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--json-data"]}," 的匹配键"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["这对于具有许多字段或嵌套有效负载的端点非常有用，因为专用标志太重。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"退出代码","__idx":9},"children":["退出代码"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"代码"},"children":["代码"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"含义"},"children":["含义"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["0"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["HTTP 请求已完成并收到响应。检查 JSON 正文以确定业务成功或失败。"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["1"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["本地 CLI 验证失败，或者当前平台不支持该命令。"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["2"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["端口解析失败、JSON解析失败或无法发送请求。"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"端口解析和故障排除","__idx":10},"children":["端口解析和故障排除"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["CLI 需要找到本地 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["httpServer"]}," 端口来发送请求。它按以下顺序检查："]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--port"]}," 标志 — 在每次调用时显式传递端口"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ML_PORT"]}," 环境变量 — 每个会话设置一次"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["IPC 自动发现 — CLI 从本地 IPC 管道读取端口（无需配置）"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["默认IPC路径："]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"平台"},"children":["平台"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"路径"},"children":["路径"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["macOS/Linux"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/tmp/MoreLogin-cli"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Windows"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["\\\\.\\pipe\\MoreLogin-cli"]}]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["如果您看到错误**“无法检测 MoreLogin 端口”**，请检查："]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["MoreLogin桌面客户端是否正在运行？"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["如果使用 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--port"]},"，端口号是否正确？"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["在 Linux / macOS 上，",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/tmp/MoreLogin-cli"]}," 是否存在？"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"文档地图","__idx":11},"children":["文档地图"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/zh/cli/quick-start"},"children":["快速入门"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/zh/cli/commands"},"children":["命令"]}]}]}]},"headings":[{"value":"CLI 概述","id":"cli-概述","depth":1},{"value":"概述","id":"概述","depth":2},{"value":"先决条件","id":"先决条件","depth":2},{"value":"下载&安装","id":"下载安装","depth":2},{"value":"Windows","id":"windows","depth":3},{"value":"macOS","id":"macos","depth":3},{"value":"Linux","id":"linux","depth":3},{"value":"核心能力","id":"核心能力","depth":2},{"value":"请求模型","id":"请求模型","depth":2},{"value":"退出代码","id":"退出代码","depth":2},{"value":"端口解析和故障排除","id":"端口解析和故障排除","depth":2},{"value":"文档地图","id":"文档地图","depth":2}],"frontmatter":{"seo":{"title":"CLI 概述"}},"lastModified":"2026-06-10T11:47:34.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/zh/cli","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}