Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lc-cn/command
指令
https://github.com/lc-cn/command
Last synced: 2 days ago
JSON representation
指令
- Host: GitHub
- URL: https://github.com/lc-cn/command
- Owner: lc-cn
- License: mit
- Created: 2022-01-13T08:46:26.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-02-09T04:11:20.000Z (almost 3 years ago)
- Last Synced: 2024-02-12T16:27:59.441Z (9 months ago)
- Language: TypeScript
- Homepage:
- Size: 9.77 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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)
})```