feat: fun new 项目脚手架——一条命令生成可运行 hello world

- fun new <名字|模块路径>:go.mod + HelloSvc.Say 示例 + README + .gitignore
- -local 写 replace 指向本地 fun 源码(离线/未发布版本也能跑)
- -port 指定示例端口;flag 手动解析可放任意位置
- 自动 go mod tidy,失败给出手动提示

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
2026-09-19 16:14:25 +08:00
co-authored by Devin
parent 759f5f65a2
commit 7d5c6b06f7
3 changed files with 174 additions and 1 deletions
+7
View File
@@ -2,6 +2,7 @@ package main
// fun-cli:fun 框架的配套命令行工具
//
// fun new 脚手架:生成可运行的 fun 项目骨架
// fun gen [ts|go] 生成 TypeScript / Go 客户端
// fun run 热更新开发循环
// fun docs 拉起 API 文档站(参数表单 + 在线发送测试)
@@ -16,6 +17,9 @@ const version = "1.4.1"
const usage = `fun-cli ` + version + ` — fun 框架配套工具
用法:
fun new <项目名|模块路径> [-port 端口]
脚手架:生成 go.mod + 示例服务 + README,go mod tidy 后即可 go run。
fun gen [ts|go] [-o 目录] [-p 模块路径] [-from meta.json]
生成客户端代码(fun 核心直接产出,与内置 GenCode 完全一致)。
扫描模块内 BindService/BindServiceForGen 调用,在对应包目录临时
@@ -30,6 +34,7 @@ const usage = `fun-cli ` + version + ` — fun 框架配套工具
流式方法实时展示 NDJSON 行。默认自动 go run 拉起后端并反向代理 /cell。
示例:
fun new myapp
fun gen ts -o frontend/src/api
fun run -p ./cmd/server
fun docs -upstream http://127.0.0.1:9000 -p .
@@ -44,6 +49,8 @@ func main() {
os.Exit(2)
}
switch os.Args[1] {
case "new":
cmdNew(os.Args[2:])
case "gen":
cmdGen(os.Args[2:])
case "run":