![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@aiot-toolkit/commander
Advanced tools
commander
仅需配置即可生成命令行工具,支持
// bin.ts
import { Command, IProgram } from '@aiot-toolkit/commander'
const config: IProgram = {
name: 'myTool',
description: 'myTool is ...',
version: '1.0.1',
// 命令列表
commandList: [
{
// 命令名称
name: 'start',
// 命令描述
description: 'start command is ...',
// 参数列表
paramList: [
{
// 参数名称
name: 'path',
// 参数描述
description: 'path is ...',
// 是否可询问(true 表示未输入时,则询问)
enableInquirer: true
},
{
name: 'path2',
description: 'path2 is ...',
enableInquirer: true
}
],
// 命令对应的方法
action: (option: any) => {
console.log(option)
},
// 常驻式操作
waiter: new PersistentCommand({
description: 'start 的常驻式操作',
options: [
{
// 按键
key: 'a',
description: 'a 的描述',
// 按下 a 执行的方法
action: () => {}
}
]
})
}
]
}
Command.registeProgram(config)
ts-node bin.ts start --path /Documents/temp
属性 | 描述 | 类型 | 必填 |
---|---|---|---|
name | 工具名称 | string | true |
description | 工具描述 | string | true |
version | 版本号 | string | true |
defaultCommand | 默认命令,无命令名称时,执行此命令 | ICommand | false |
commandList | 命令列表 | ICommand[] | false |
属性 | 描述 | 类型 | 必填 |
---|---|---|---|
name | 命令名称 | string | true |
description | 命令描述 | string | true |
argumentList | 无名称参数, tool arg1 arg2 | string[] | false |
paramList | 有名称参数 | ParamType | false |
action | 命令的执行函数,action:(arg1, arg2, options)=>{} | true |
ParamType 分为4类,继承自IParam
参数基础结构
属性 | 描述 | 类型 | 必填 |
---|---|---|---|
name | 参数名称 | string | true |
description | 参数描述 | string | true |
defaultValue | 默认值 | any | false |
enableInquirer | 是否启用交互式询问 | boolean | false |
deprecated | 废弃的提示信息, 如果有值,表示此参数已废弃 | string | |
deprecatedVersion | 废弃的版本号 | string |
文本式参数,在IParam的基础上,增加
属性 | 描述 | 类型 | 必填 |
---|---|---|---|
type | 固定值 string | 'string' | true |
validate | 校验输入合法性的方法 | Function | false |
单选参数,在 IParam 的基础上,增加
属性 | 描述 | 类型 | 必填 |
---|---|---|---|
type | 固定值 select | 'select' | true |
choices | 选项列表 | { value:选项值(必填), name:选项名称(可选), description: 描述(可选) }[] | true |
多选参数,在SelectParam 基础上,修改
属性 | 描述 | 类型 | 必填 |
---|---|---|---|
type | 固定值 checkbox | 'checkbox' | true |
boolean 参数,在 IParam 的基础上,增加
属性 | 描述 | 类型 | 必填 |
---|---|---|---|
type | 固定值 confirm | 'confirm' | true |
属性 | 描述 | 类型 | 必填 |
---|---|---|---|
description | 常驻命令描述 | string | true |
options | 常驻命令列表 | IPersistentCommandItem[] | true |
属性 | 描述 | 类型 | 必填 |
---|---|---|---|
key | 按键,只能是一个字符 | string | true |
description | 描述 | string | true |
action | 按键执行的方法 | () => Promise, ()=>void | true |
FAQs
A tool that generates complete commands with configuration
The npm package @aiot-toolkit/commander receives a total of 121 weekly downloads. As such, @aiot-toolkit/commander popularity was classified as not popular.
We found that @aiot-toolkit/commander demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.