Skip to content

Commit

Permalink
Merge pull request #149 from suyuan32/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
suyuan32 authored Jul 9, 2023
2 parents 8fd03da + f5488ff commit cb48aa6
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 2 deletions.
1 change: 1 addition & 0 deletions tools/goctl/info/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func init() {
)

envCmdFlags.StringVarPWithDefaultValue(&env.ServiceName, "service_name", "s", "core")
envCmdFlags.BoolVarP(&env.ShowList, "list", "l")

Cmd.AddCommand(EnvCmd)
Cmd.AddCommand(PortCmd)
Expand Down
9 changes: 9 additions & 0 deletions tools/goctl/info/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@ import (

var (
ServiceName string
ShowList bool
)

// ShowEnv is used to show the environment variable usages.
func ShowEnv(_ *cobra.Command, _ []string) error {
if ShowList {
getServiceList()
return nil
}

if lang {
color.Green.Println("Simple Admin的环境变量")
color.Red.Println("注意: 环境变量的优先级大于配置文件")
Expand All @@ -46,6 +52,9 @@ func ShowEnv(_ *cobra.Command, _ []string) error {
captchaEnvInfo()
case "fms":
fmsEnvInfo()
case "mcms":
mcmsEmailEnvInfo()
mcmsSmsEnvInfo()
}

return nil
Expand Down
64 changes: 64 additions & 0 deletions tools/goctl/info/env/mcms.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package env

import (
"github.com/gookit/color"
"github.com/jedib0t/go-pretty/v6/table"
"os"
)

func mcmsEmailEnvInfo() string {
color.Green.Println("MCMS")
color.Green.Println("EMAIL")
envInfo = table.NewWriter()
envInfo.SetOutputMirror(os.Stdout)
if lang {
envInfo.AppendHeader(table.Row{"环境变量名称", "环境变量介绍"})
envInfo.AppendRows([]table.Row{
{"EMAIL_AUTH_TYPE", "电子邮箱的认证类型,支持plain和CRAMMD5"},
{"EMAIL_ADDR", "电子邮箱地址"},
{"EMAIL_PASSWORD", "电子邮箱密码"},
{"EMAIL_HOST_NAME", "电子邮箱的服务器地址"},
{"EMAIL_PORT", "电子邮箱的服务器端口"},
{"EMAIL_IDENTIFY", "电子邮箱的身份信息,用于CRAMMD5"},
{"EMAIL_SECRET", "电子邮箱的密钥信息,用于CRAMMD5"},
{"EMAIL_TLS", "是否启用TLS"},
})
} else {
envInfo.AppendHeader(table.Row{"Key", "Introduction"})
envInfo.AppendRows([]table.Row{
{"EMAIL_AUTH_TYPE", "Authentication type for the email, supports plain and CRAMMD5"},
{"EMAIL_ADDR", "Email address"},
{"EMAIL_PASSWORD", "Email password"},
{"EMAIL_HOST_NAME", "Server address for the email"},
{"EMAIL_PORT", "Server port for the email"},
{"EMAIL_IDENTIFY", "Identity information for the email, used for CRAMMD5"},
{"EMAIL_SECRET", "Secret information for the email, used for CRAMMD5"},
{"EMAIL_TLS", "Whether to enable TLS"},
})
}
return envInfo.Render()
}

func mcmsSmsEnvInfo() string {
color.Green.Println("SMS")
envInfo = table.NewWriter()
envInfo.SetOutputMirror(os.Stdout)
if lang {
envInfo.AppendHeader(table.Row{"环境变量名称", "环境变量介绍"})
envInfo.AppendRows([]table.Row{
{"SMS_SECRET_ID", "短信服务密钥ID"},
{"SMS_SECRET_KEY", "短信服务密钥"},
{"SMS_PROVIDER", "短信服务提供商"},
{"SMS_REGION", "短信服务提供区域"},
})
} else {
envInfo.AppendHeader(table.Row{"Key", "Introduction"})
envInfo.AppendRows([]table.Row{
{"SMS_SECRET_ID", "Secret ID for the SMS service"},
{"SMS_SECRET_KEY", "Secret key for the SMS service"},
{"SMS_PROVIDER", "Provider for the SMS service"},
{"SMS_REGION", "Region for the SMS service"},
})
}
return envInfo.Render()
}
30 changes: 30 additions & 0 deletions tools/goctl/info/env/service_list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package env

import (
"github.com/gookit/color"
"github.com/jedib0t/go-pretty/v6/table"
"os"
)

// getServiceList returns the service list
func getServiceList() string {
color.Green.Println("Service ")
envInfo = table.NewWriter()
envInfo.SetOutputMirror(os.Stdout)
if lang {
envInfo.AppendHeader(table.Row{"服务名称", "服务介绍"})
envInfo.AppendRows([]table.Row{
{"core", "核心服务"},
{"fms", "文件服务"},
{"mcms", "消息中心服务"},
})
} else {
envInfo.AppendHeader(table.Row{"Service name", "Introduction"})
envInfo.AppendRows([]table.Row{
{"core", "Core Service"},
{"fms", "File Management Service"},
{"mcms", "Message Center Service"},
})
}
return envInfo.Render()
}
3 changes: 2 additions & 1 deletion tools/goctl/internal/flags/default_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@
"short": "View additional information, such as environment variables and project port usage.",
"env": {
"short": "View environment variables.",
"service_name": "Service name, support: core, fms"
"service_name": "Service name, support: core, fms, mcms",
"list": "Show the list of supported services"
},
"port": {
"short": "View port usage."
Expand Down
3 changes: 2 additions & 1 deletion tools/goctl/internal/flags/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@
"short": "查看额外信息,如环境变量和项目端口使用情况",
"env": {
"short": "查看环境变量",
"service_name": "服务名称,支持: core, fms"
"service_name": "服务名称,支持: core, fms, mcms",
"list": "列出支持的服务"
},
"port": {
"short": "查看端口使用情况"
Expand Down

0 comments on commit cb48aa6

Please sign in to comment.