mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
add command gen service for cli
This commit is contained in:
@ -109,7 +109,7 @@ func init() {
|
||||
|
||||
type cBuildInput struct {
|
||||
g.Meta `name:"build" config:"gfcli.build"`
|
||||
File string `name:"FILE" arg:"true" brief:"building file path"`
|
||||
File string `name:"FILE" arg:"true" brief:"building file path"`
|
||||
Name string `short:"n" name:"name" brief:"output binary name"`
|
||||
Version string `short:"v" name:"version" brief:"output binary version"`
|
||||
Arch string `short:"a" name:"arch" brief:"output binary architecture, multiple arch separated with ','"`
|
||||
|
||||
@ -2,12 +2,13 @@ package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/v2/os/gproc"
|
||||
)
|
||||
|
||||
var (
|
||||
// gofmtPath is the binary path of command `gofmt`.
|
||||
gofmtPath = gproc.SearchBinaryPath("gofmt")
|
||||
gofmtPath = gproc.SearchBinaryPath("gofmt") // gofmtPath is the binary path of command `gofmt`.
|
||||
goimportsPath = gproc.SearchBinaryPath("goimports") // gofmtPath is the binary path of command `goimports`.
|
||||
)
|
||||
|
||||
// GoFmt formats the source file using command `gofmt -w -s PATH`.
|
||||
@ -16,3 +17,10 @@ func GoFmt(path string) {
|
||||
gproc.ShellExec(fmt.Sprintf(`%s -w -s %s`, gofmtPath, path))
|
||||
}
|
||||
}
|
||||
|
||||
// GoImports formats the source file using command `goimports -w PATH`.
|
||||
func GoImports(path string) {
|
||||
if goimportsPath != "" {
|
||||
gproc.ShellExec(fmt.Sprintf(`%s -w %s`, goimportsPath, path))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user