跳到主要内容

CLI 命令

概览​

ONES 开发平台诊断工具 CLI 命令。

备注

开发者调用 CLI 的指令模版:diagtools [command] [arguments] [options]

索引​

指令名称指令描述
help展示 Diagtools CLI 的帮助信息
autocomplete显示命令行「自动完成」安装说明
config set设置当前配置文件的配置
config get获取当前配置文件的配置
config delete删除当前配置文件的配置
config list列出当前配置文件的所有配置
profile create创建一个配置文件
profile use切换使用指定配置文件
profile delete删除指定配置文件
profile list列出所有配置文件
log打印组件日志
list列出组件状态
dump转储当前时刻数据

命令​

help​

展示 Diagtools CLI 的帮助信息。

diagtools help [COMMAND]

参数​

参数名称参数描述
COMMAND需要显示帮助信息的 Diagtools CLI 提供的任意 命令

选项​

选项名称选项别名选项描述
--nested-commands-n输出是否包含子命令

示例​

$ diagtools help autocomplete
display autocomplete installation instructions

USAGE
$ diagtools autocomplete [SHELL] [-r]

ARGUMENTS
SHELL shell type

FLAGS
-r, --refresh-cache Refresh cache (ignores displaying instructions)

DESCRIPTION
display autocomplete installation instructions

EXAMPLES
$ diagtools autocomplete

$ diagtools autocomplete bash

$ diagtools autocomplete zsh

$ diagtools autocomplete --refresh-cache

autocomplete​

显示命令行「自动完成」安装说明。

diagtools autocomplete [SHELL]

参数​

参数名称参数描述
SHELL终端类型

选项​

选项名称选项别名选项描述
--refresh-cache-r刷新缓存(忽略显示的指令)

示例​

$ diagtools autocomplete
Building the autocomplete cache... done

Setup Instructions for DIAGTOOLS CLI Autocomplete ---

1) Add the autocomplete env var to your zsh profile and source it
$ printf "eval $(diagtools autocomplete:script zsh)" >> ~/.zshrc; source ~/.zshrc

NOTE: After sourcing, you can run `$ compaudit -D` to ensure no permissions conflicts are present

2) Test it out, e.g.:
$ diagtools <TAB> # Command completion
$ diagtools command --<TAB> # Flag completion

Enjoy!

根据提示,运行提示命令

$ printf "eval $(diagtools autocomplete:script zsh)" >> ~/.zshrc
$ source ~/.zshrc

尝试使用补全功能

$ diagtools l <TAB>
list -- list the component status
log -- print a component logs

config set​

设置当前配置文件的配置。

diagtools config set KEY VALUE

参数​

参数名称参数描述
KEY配置变量名
VALUE配置变量值

选项​

选项名称选项描述
--verbose详细输出

示例​

$ diagtools config set address tcp://127.0.0.1:30002
config set successfully

config get​

获取当前配置文件的配置。

diagtools config get KEY

参数​

参数名称参数描述
KEY配置变量名

选项​

选项名称选项描述
--verbose详细输出

示例​

$ diagtools config get address
tcp://127.0.0.1:30002

config delete​

删除当前配置文件的配置。

diagtools config delete KEY

参数​

参数名称参数描述
KEY配置变量名

选项​

选项名称选项描述
--verbose详细输出

示例​

$ diagtools config delete address
config delete successfully

config list​

列出当前配置文件的所有配置。

diagtools config list

选项​

选项名称选项描述
--verbose详细输出

示例​

$ diagtools config list
address = tcp://127.0.0.1:30002

profile create​

创建一个配置文件。

警告

此命令并不会帮你切换使用新配置,你需要使用 profile use 手动切换。

diagtools profile create NAME

参数​

参数名称参数描述
NAME新配置文件名

选项​

选项名称选项描述
--verbose详细输出

示例​

diagtools profile create example
The example profile successfully created

profile use​

切换使用指定配置文件。

diagtools profile use NAME

参数​

参数名称参数描述
NAME配置文件名

选项​

选项名称选项描述
--verbose详细输出

示例​

$ diagtools profile use example
The example profile successfully switched

profile delete​

删除指定配置文件。

diagtools profile delete NAME

参数​

参数名称参数描述
NAME配置文件名

选项​

选项名称选项描述
--verbose详细输出

示例​

$ diagtools profile delete example
The example profile successfully deleted

profile list​

列出所有配置文件。

diagtools profile list

选项​

选项名称选项描述
--verbose详细输出

示例​

$ diagtools profile list
example

log​

打印组件日志。

diagtools log TYPE

参数​

参数名称参数描述
TYPE组件类型,选项:(platform, host, plugin)

选项​

选项名称选项别名选项描述
--verbose详细输出
--address <value>覆盖配置中 address 属性执行
--organizationUUID <value>覆盖配置中 organizationUUID 属性执行
--teamUUID <value>覆盖配置中 teamUUID 属性执行
--extended-x展示额外的列
--columns <value>仅显示提供的列(逗号分隔)
--filter <value>通过字符串匹配过滤属性,例如:name=foo
--from <value>读取本地文件(该值可以是相对路径或绝对路径)

示例​

$ diagtools log plugin --id ce1f55d2
{"Level":"Info","Message":"[Plugin] Install","Time":"2022/11/29 14:55:27"}
{"Level":"Info","Message":"[Plugin] Enable","Time":"2022/11/29 14:56:05"}

list​

列出组件状态。

diagtools list TYPE

参数​

参数名称参数描述
TYPE组件类型,选项:(plugins, abilities, components)

选项​

选项名称选项别名选项描述
--verbose详细输出
--address <value>覆盖配置中 address 属性执行
--organizationUUID <value>覆盖配置中 organizationUUID 属性执行
--teamUUID <value>覆盖配置中 teamUUID 属性执行
--extended-x展示额外的列
--csv--output=csvcsv 格式输出
--output <option>以更加计算机友好的格式输出 (选项:csv, json, yaml)
--columns <value>仅显示提供的列(逗号分隔)
--filter <value>通过字符串匹配过滤属性,例如:name=foo
--from <value>读取本地文件(该值可以是相对路径或绝对路径)
--no-header隐藏表头输出
--no-truncate不要截断输出以适合屏幕
--sort <value>根据标题属性排序(以'-'开头为降序)

示例​

$ diagtools list plugins
InstanceID AppName AppID AppVersion Scope ScopeUUID HostID IsLocal Status RealStatus Apis
────────── ────────── ───────── ────────── ──────────── ───────── ────── ─────── ────────────── ────────────── ────────────────────────────────────────
ce1f55d2 Example FSksKfHR3 1.0.0 Team Pgg7h253 false DisableSuccess DisableSuccess [{""Methods":["POST"],"Url":"/hello",...

dump​

转储当前时刻数据。

diagtools dump PATH

参数​

参数名称参数描述
PATH转储路径,该值可以是相对路径或绝对路径

选项​

选项名称选项描述
--verbose详细输出
--address <value>覆盖配置中 address 属性执行
--organizationUUID <value>覆盖配置中 organizationUUID 属性执行
--teamUUID <value>覆盖配置中 teamUUID 属性执行

示例​

$ diagtools dump .
dump successfully