2 Star 1 Fork 1

mosache / YFrame

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
gen.go 980 Bytes
一键复制 编辑 原始数据 按行查看 历史
ヤ沒脩袮兲︶ 提交于 2023-04-04 15:23 . add Y api doc command
package api
import (
"bytes"
"errors"
"fmt"
"gitee.com/mosache/YFrame/tools/Y/utils/cobraErr"
"github.com/logrusorgru/aurora"
"github.com/spf13/cobra"
"os/exec"
)
var apiGenCmd = &cobra.Command{Use: "gen",
Short: "gen from api file",
Long: `gen from api file`,
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
if err := apiFileGen(cmd); err != nil {
cobraErr.Err(cmd, err.Error())
}
return nil
},
}
func apiFileGen(cmd *cobra.Command) error {
var (
in bytes.Buffer
out bytes.Buffer
errOut bytes.Buffer
err error
)
c := exec.Command("goctl", "api",
"go", "--home", "./.tpls", "--api", "./api/base.api", "--dir", ".")
c.Stdin = &in
c.Stdout = &out
c.Stderr = &errOut
if err = c.Run(); err != nil {
if errOut.Len() > 0 {
return errors.New(errOut.String())
}
return err
}
if errOut.Len() > 0 {
return errors.New(errOut.String())
}
fmt.Println(aurora.Green("DONE!"))
return nil
}
Go
1
https://gitee.com/mosache/YFrame.git
git@gitee.com:mosache/YFrame.git
mosache
YFrame
YFrame
v0.1.73

搜索帮助