deb3cc71bf
按报告 v1.0.4 路线图完成 5 项开发体验与文档改进: #25 模块路径文档改进: - 保留 -core 后缀(xlgo 是多产品系列:xlgo-core/xlgo-orm/xlgo-ai) - README 快速开始补完整 import 示例 + 新增「模块路径与包名」小节 - CLAUDE.md Import Path Note 措辞明确化 #27 Without* Option 定位文档化: - 调研确认 Without* 有真实用例(测试覆盖 + NewFullStack 后排除单项) - 不删不标 Deprecated,在 app.go 注释 + README 说明其定位 #28 CLI 多模板: - xlgo new --template minimal/api/fullstack - minimal 轻量HTTP无依赖,api 标准业务分层(默认),fullstack 全组件 - 三模板实测生成正确 #29 examples/ 目录: - examples/minimal(50行可跑,无外部依赖) - examples/full(mysql+redis+jwt+user CRUD) - examples/README.md #30 文档结构: - Version_*.md + report.md 移到 docs/plans/(v2.0-review.md) - 新增 docs/README.md 索引 - CHANGELOG/GUIDE 留根目录(按惯例) - .gitignore 整理 build/vet/test + examples 编译全绿。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
65 lines
1.5 KiB
Go
65 lines
1.5 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
xlgo "github.com/EthanCodeCraft/xlgo-core"
|
|
)
|
|
|
|
func printUsage() {
|
|
fmt.Println(`xlgo - Go Web 框架脚手架工具
|
|
|
|
用法:
|
|
xlgo new <项目名> [--template <模板>] [--module <模块路径>] 创建新项目
|
|
xlgo make handler <名称> 创建处理器
|
|
xlgo make repository <名称> 创建仓库
|
|
xlgo make model <名称> 创建模型
|
|
xlgo make service <名称> 创建服务
|
|
xlgo version 显示版本号
|
|
|
|
模板 (xlgo new --template <名称>):
|
|
minimal 轻量 HTTP 服务,不依赖 MySQL/Redis(默认入门)
|
|
api 标准业务 API,含 MySQL/Redis/JWT 与 handler/model/repository/service 分层(默认)
|
|
fullstack 全组件,一键启用 MySQL/Redis/Storage/Swagger/AutoMigrate
|
|
|
|
示例:
|
|
xlgo new myapp
|
|
xlgo new myapp --template minimal
|
|
xlgo new myapp --template fullstack --module github.com/me/myapp
|
|
xlgo make handler user
|
|
xlgo make repository user`)
|
|
}
|
|
|
|
func main() {
|
|
if len(os.Args) < 2 {
|
|
printUsage()
|
|
return
|
|
}
|
|
|
|
command := os.Args[1]
|
|
|
|
switch command {
|
|
case "new":
|
|
if len(os.Args) < 3 {
|
|
fmt.Println("用法: xlgo new <项目名>")
|
|
return
|
|
}
|
|
createProject(os.Args[2])
|
|
|
|
case "make":
|
|
if len(os.Args) < 4 {
|
|
fmt.Println("用法: xlgo make <类型> <名称>")
|
|
fmt.Println("类型: handler, repository, model, service")
|
|
return
|
|
}
|
|
makeFile(os.Args[2], os.Args[3])
|
|
|
|
case "version":
|
|
fmt.Printf("xlgo v%s\n", xlgo.Version)
|
|
|
|
default:
|
|
printUsage()
|
|
}
|
|
}
|