Skip to main content
Home
This release is 1 version behind 0.1.6 — the latest version of @24wings/cli. Jump to latest

Built and signed on GitHub Actions

Works with
This package works with Deno, Browsers
This package works with Deno
This package works with Browsers
JSR Score41%
Published10 months ago (0.1.5)

zero code make cli program

0行代码制作命令行程序

通过jsdoc 为文件或者模块 生成cli 并调用cli

安装

deno install -A -g --name  cli jsr:@24wings/cli/cli.ts

例如 你的代码

// my_hello.ts

/**
@param name  you can set the name you use
*/
export function hello(name:string){
    return {msg:`hello ${name}`}
}

/**
@param name  you can set the name you use2
*/
export function hello2(name:string){
    return {msg:`hello ${name}`}
}


其中@param name 不是必须的,如果编写则会变成参数的文档 也是命令行的参数的文档 你可以直接以命令行的形式运行


cli  ./my-hello.ts  --help

会列出模块中的所有函数作为子命令

也可以执行子命令查看文档

cli ./my-hello.ts hello --help

-log 是生成的内置命令,用于打印函数的结果

  cli ./my-hello.ts hello --name zhangsan -log

cli jsr:@std/path dirname --help

原理

通过deno doc --json 转换为文档对象 并转换为 gunshi的cli参数

待新增的特性

  • 可选参数与cli 可选参数映射
  • 支持参数复杂对象
  • 输出格式 json ,xml,jsonl,
  • logtap类日志库的约束输出
  • 更好的配合nushell使用
  • 交互式shell
  • 自动化简略参数
  • 包模式,将整个包或者目录下的模块(mod.ts)作为交互式app使用
Built and signed on
GitHub Actions

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.