1.0.10 • Published 5 months ago

@yangsansuan/citty v1.0.10

Weekly downloads
-
License
ISC
Repository
-
Last release
5 months ago

编写命令行工具,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

  1. 安装
npm i @yangsansuan/citty -S
  1. 编写你的脚本
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)
  1. 配置package.json
{
    "bin": {
        "mycli": "dist/xx.js"
    }
}
  1. 发布后安装运行
mycli dev
1.0.10

5 months ago

1.0.9

5 months ago