2 Star 1 Fork 2

go-mao / mao

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.go 1.49 KB
一键复制 编辑 原始数据 按行查看 历史
haitgo 提交于 2023-12-01 10:12 . 调整日志输出的格式
package main
import (
"fmt"
"os"
"strings"
"gitee.com/go-mao/mao/frame"
)
func main() {
args := os.Args[1:]
if len(args) == 0 {
fmt.Println("参数不能为空 ")
return
}
argsLen := len(args)
if args[0] == "new" {
if argsLen < 3 {
fmt.Println("请输入:mao 命令 参数... ")
fmt.Println(`
命令 new:
子命令:
app 创建一个web项目,例如:mao new app blog
mod 创建一个web模块,例如:mao new mod pay ;(注意执行命令所在的目录)
comop 创建一个web组件,例如:mao new comp user; (注意执行命令所在的目录)
`)
return
}
action, name := args[1], args[2]
switch action {
case "app":
mod = name
copyDir("demo/app", name)
writeMod(name)
case "module", "mod":
copyDir("demo/app/modules/demo", name)
case "comp", "component":
copyDir("demo/app/modules/demo/components/user", name)
}
} else if args[0] == "version" {
fmt.Println(frame.VERSION)
} else {
fmt.Println("参数错误")
return
}
}
var mod string
// 获取当前应用的mod名称
func getModName() string {
if mod != "" {
return mod
}
workPath := getWorPath()
for index, item := range workPath {
if item == "modules" {
mod = workPath[index-1]
return mod
}
}
fmt.Println("请确认所在目录是否为web项目")
os.Exit(0)
return ""
}
func getWorPath() []string {
workDir, _ := os.Getwd()
workDir = strings.ReplaceAll(workDir, `\`, "/")
workDir = strings.TrimSuffix(workDir, "/")
return strings.Split(workDir, "/")
}
1
https://gitee.com/go-mao/mao.git
git@gitee.com:go-mao/mao.git
go-mao
mao
mao
v1.0.24

搜索帮助