Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lc-cn/command

指令
https://github.com/lc-cn/command

Last synced: 2 days ago
JSON representation

指令

Awesome Lists containing this project

README

        

# command
指令系统
## Usage
1.安装
```shell
npm install @lc-cn/command
```
2.样例
```typescript
import {defineCommand} from "@lc-cn/command";
function sleep(ms){
return new Promise(resolve => {
setTimeout(resolve,ms)
})
}
const cmd=defineCommand('test [b:number]')
.option('hello','-h ')
.option('world','-w')
.action(async ({options},a,b)=>{
console.log('我是传入的参数',[a,b])
await sleep(3000)
console.log('我3秒后返回')
return options
})
cmd.execute('test asdf 22 -h 你好 -w').then((res)=>{
console.log(res)
}).catch(e=>{
console.error(e.message)
})

```