百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

citty

> 编程语言
开源

优雅的 CLI 构建器

1.3K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

优雅的 CLI 构建器

citty Elegant CLI Builder - 无依赖性,快速轻量级(基于原生 util.parseArgs) - 智能解析值,支持类型转换和布尔缩写 - 可嵌套的子命令,支持延迟加载和异步加载 - 可插入和组合的 API,支持自动生成使用说明 - 使用方法 ```sh

npx nypm add -D citty … sh node index.mjs john

Greetings john!

- 子命令 子命令可以递归嵌套。对于大型 CLI,使用延迟导入来避免一次加载所有命令。js import { defineCommand, runMain } from "citty";

const sub = defineCommand({ meta: { name: "sub", description: "Sub command" }, args: { name: { type: "positional", description: "Your name", required: true }, }, run({ args }) { console.log(Hello ${args.name}!); }, });

const main = defineCommand({ meta: { name: "hello", version: "1.0.0", description: "My Awesome CLI App" }, subCommands: { sub }, });

runMain(main); 子命令支持 `meta.alias`(例如, `["i", "add"]`) 和 `meta.hidden: true` 来隐藏在帮助输出中。 - 延迟加载命令 对于大型 CLI,延迟加载子命令,以便只导入执行的命令:js const main = defineCommand({ meta: { name: "hello", version: "1.0.0", description: "My Awesome CLI App" }, subCommands: { sub: () => import("./sub.mjs").then((m) => m.default), }, });


`meta`,`args`和`subCommands`都接受`Resolvable`值 - 一个值、Promise、函数或异步函数 - 从而支持延迟和动态解析。

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScript

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言