1.0.10 • Published 5 months ago
@yangsansuan/citty v1.0.10
编写命令行工具,copy from unjs/citty
Features
✅ Fast and lightweight argument parser based on mri 🔲 Smart value parsing with typecast, boolean shortcuts and unknown flag handling ✅ Nested sub-commands 🔲 Lazy and Async commands 🔲 Plugable and composable API 🔲 Auto generated usage and help
Usage
- 安装
npm i @yangsansuan/citty -S
- 编写你的脚本
import { defineCommond, runMain } from '@yangsansuan/citty'
const cmd = defineCommond({
meta: {
name: 'mycli',
description: '命令行描述',
version: '1.0.0'
},
subCommands: {
dev: {
meta: {...},
args: {
port: {
type: 'string',
description: '端口号',
default: 3000
},
...
},
run() {
console.log(123)
}
},
build: {...}
}
})
runMain(cmd)
- 配置package.json
{
"bin": {
"mycli": "dist/xx.js"
}
}
- 发布后安装运行
mycli dev