1 Star 0 Fork 0

ichub/gotestframe

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
menu.go 3.90 KB
一键复制 编辑 原始数据 按行查看 历史
leijmdas 提交于 2024-09-01 16:40 . add
package menu
import (
"fmt"
"gitee.com/ichub/goconfig/cmd/goconfig/gomenu"
"gitee.com/ichub/goconfig/common/ichubconfig"
"gitee.com/ichub/gomini/mini/cyclomaticcomplex"
"gitee.com/ichub/gotestframe/testframe/cmd/testframe/godimenu"
"gitee.com/ichub/gotestframe/testframe/cmd/testframe/install"
"gitee.com/ichub/goweb/common/webclient"
"gitee.com/ichub/goweb/websample/server/webstart"
"github.com/gogf/gf/v2/util/gconv"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
var serverCmd = &cobra.Command{
Use: "server",
Short: "start web server",
Run: startServer,
}
var LisCfgCmd = &cobra.Command{
Use: "cfg",
Short: "list config of project",
Run: ListCfg,
}
var ccCheckAllCmd = &cobra.Command{
Use: "ccall",
Short: "ccall : a tool of gomini menu",
Long: `This is a gomini cc check using Cobra`,
Run: func(cmd *cobra.Command, args []string) {
if len(cmd.Flags().Args()) > 0 {
flag := cmd.Flags().Arg(0)
cyclomaticcomplex.FindBeanCyclomaticComplex().CcCheckScan(gconv.Int(flag))
return
}
cyclomaticcomplex.FindBeanCyclomaticComplex().CcCheckAllScan()
},
}
var ccCheckCmd = &cobra.Command{
Use: "cc",
Short: "cc : a tool of gomini menu",
Long: `This is a gomini cc check using Cobra`,
Run: func(cmd *cobra.Command, args []string) {
if len(cmd.Flags().Args()) > 0 {
flag := cmd.Flags().Arg(0)
cyclomaticcomplex.FindBeanCyclomaticComplex().CcCheckScan(gconv.Int(flag))
return
}
cyclomaticcomplex.FindBeanCyclomaticComplex().CcCheckScan()
},
}
var ccCheckFileCmd = &cobra.Command{
Use: "ccfile",
Short: "ccfile filename : a tool of gomini menu",
Long: `This is a gomini cc check using Cobra`,
Run: func(cmd *cobra.Command, args []string) {
if len(cmd.Flags().Args()) == 0 {
fmt.Println("please enter file ")
return
}
file := cmd.Flags().Arg(0)
if len(cmd.Flags().Args()) > 1 {
flag := cmd.Flags().Arg(1)
cyclomaticcomplex.FindBeanCyclomaticComplex().CcCheckFileScan(file, gconv.Int(flag))
return
}
cyclomaticcomplex.FindBeanCyclomaticComplex().CcCheckFileScan(file)
},
}
func ListCfg(cmd *cobra.Command, args []string) {
fmt.Println("list config of project")
var cfg = ichubconfig.FindBeanIchubConfig()
fmt.Println(cfg.ReadIchubWebClient())
}
var ListServiceCmd = &cobra.Command{
Use: "service",
Short: "list service of project",
Run: ListService,
}
func ListService(cmd *cobra.Command, args []string) {
fmt.Println("list service of project")
var webcli = webclient.FindBeanIchubWebClient().Init()
fmt.Println(webcli.GetServiceAddr())
}
var ListPathCmd = &cobra.Command{
Use: "path",
Short: "list path of project",
Run: ListPath,
}
func ListPath(cmd *cobra.Command, args []string) {
fmt.Println("view path of goweb")
install.FindBeanWebIni().Ls()
}
var testCmd = &cobra.Command{
Use: "test",
Short: "test web server",
Run: TestWeb,
}
func init() {
var factroy = gomenu.FindBeanGomenuFactroy()
factroy.SetVersion("v1.0")
factroy.SetCmdName("goweb")
factroy.SetBasePkg("gitee.com/ichub/gotestframe/testframe/cmd/testframe/menu")
factroy.Init()
factroy.AddCommands(ccCheckCmd, ccCheckFileCmd, ccCheckAllCmd)
factroy.AddSubCmds("web", serverCmd, testCmd)
factroy.AddSubCmds("list", ListPathCmd, ListServiceCmd, LisCfgCmd)
factroy.AddSubCmds("install", install.InstallDocxCmd, install.InstallDockerCmd,
install.InstallAllCmd, install.InstallCmd, install.InstallWeb, install.InstallConfig)
factroy.AddSubCmds("di", godimenu.ForceCmd,
godimenu.AllCmd, godimenu.FileCmd, godimenu.StruCmd,
godimenu.ListStruCmd, godimenu.OptCmd)
factroy.AddSubCmds("suite", godimenu.SuiteOneCmd,
godimenu.SuiteCmdForce, godimenu.SuiteCmdAll)
}
func Execute() {
gomenu.FindBeanGomenuFactroy().Execute()
}
func startServer(cmd *cobra.Command, args []string) {
// 启动服务逻辑
webstart.StartWeb()
}
func TestWeb(cmd *cobra.Command, args []string) {
var webClient = webclient.Default()
var result = webClient.Get("/")
logrus.Info(result)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/ichub/gotestframe.git
git@gitee.com:ichub/gotestframe.git
ichub
gotestframe
gotestframe
23f7283181f7

搜索帮助

0d507c66 1850385 C8b1a773 1850385