1 Star 0 Fork 0

庞飞/multiapp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
modelcache.go 1.31 KB
一键复制 编辑 原始数据 按行查看 历史
庞飞 提交于 2023-10-03 17:10 . 合并主框架
package modelcache
import (
"fmt"
"gitee.com/pangxianfei/multiapp/config"
"gitee.com/pangxianfei/multiapp/cmd"
)
func init() {
cmd.Add(&ModelCache{})
}
type ModelCache struct {
}
func (s *ModelCache) Command() string {
return "modelcache:make {appname} {name}"
}
func (s *ModelCache) Description() string {
return "Create a AppName Model Cache"
}
func (s *ModelCache) Handler(arg *cmd.Arg) error {
appname, aErr := arg.Get("appname")
if aErr != nil {
return aErr
}
modelCacheName, rErr := arg.Get("name")
if rErr != nil {
return rErr
}
if appname == nil {
cmd.Warning("You need a app name")
return nil
}
if modelCacheName == nil {
cmd.Warning("You need a Model Cache name")
return nil
}
var AppPath string = config.GetString("app.app_path")
var stubsModelCacheNamePath string = fmt.Sprintf("%s/make/stubs/modelcache", config.GetString("app.make_stubs"))
newAppName := string(*appname)
newModelCacheName := string(*modelCacheName)
createModel := cmd.Model{}
Models := createModel.MakeModelFromString(newAppName, newModelCacheName)
// 拼接目标文件路径
filePath := fmt.Sprintf("%s/%s/buffer/%sCache.go", AppPath, Models.AppName, Models.StructName)
// 基于模板创建文件(做好变量替换)
createModel.CreateFileFromStub(filePath, stubsModelCacheNamePath, Models)
return nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/pangxianfei/multiapp.git
git@gitee.com:pangxianfei/multiapp.git
pangxianfei
multiapp
multiapp
v1.1.9

搜索帮助

0d507c66 1850385 C8b1a773 1850385