Skip to content

Commit

Permalink
规范 migrate 输出
Browse files Browse the repository at this point in the history
  • Loading branch information
trheyi committed Feb 9, 2022
1 parent 385f42c commit 5407525
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions cmd/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var migrateCmd = &cobra.Command{
// 加载数据模型
err := engine.Load(config.Conf)
if err != nil {
fmt.Printf(color.RedString("加载失败: %s\n", err.Error()))
fmt.Println(color.RedString(L("Fatal: %s"), err.Error()))
os.Exit(1)
}

Expand All @@ -35,12 +35,12 @@ var migrateCmd = &cobra.Command{

// Do Stuff Here
for _, mod := range gou.Models {
fmt.Println(color.GreenString("更新数据模型 %s 绑定数据表: %s", mod.Name, mod.MetaData.Table.Name))
fmt.Println(color.GreenString(L("Update schema model: %s (%s) "), mod.Name, mod.MetaData.Table.Name))
mod.Migrate(true)
}
},
}

func init() {
migrateCmd.PersistentFlags().StringVarP(&name, "name", "n", "", "指定模型名称")
migrateCmd.PersistentFlags().StringVarP(&name, "name", "n", "", L("Model name"))
}
2 changes: 2 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ var langs = map[string]string{
"Run: %s": "运行: %s",
"Arguments: %s": "参数错误: %s",
"%s Response": "%s 返回结果",
"Update schema model: %s (%s) ": "更新表结构 model: %s (%s)",
"Model name": "模型名称",
}

// L 多语言切换
Expand Down
2 changes: 1 addition & 1 deletion cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var startCmd = &cobra.Command{
mode := config.Conf.Mode
err := engine.Load(config.Conf) // 加载脚本等
if err != nil {
fmt.Printf(color.RedString(L("Fatal: %s"), err.Error()))
fmt.Println(color.RedString(L("Fatal: %s"), err.Error()))
os.Exit(1)
}
port := fmt.Sprintf(":%d", config.Conf.Port)
Expand Down

0 comments on commit 5407525

Please sign in to comment.