mirror of
https://gitee.com/energye/energy.git
synced 2024-11-29 18:28:06 +08:00
添加命令行工具
This commit is contained in:
parent
1cbaa491d9
commit
59c65fc066
13
cmd/command.go
Normal file
13
cmd/command.go
Normal file
@ -0,0 +1,13 @@
|
||||
package cmd
|
||||
|
||||
type CommandConfig struct {
|
||||
Install Install `command:"install"`
|
||||
Package Package `command:"package"`
|
||||
}
|
||||
|
||||
type Install struct {
|
||||
Path string `short:"m" long:"path" description:"Installation directory Default current directory"`
|
||||
}
|
||||
|
||||
type Package struct {
|
||||
}
|
32
cmd/energy/energy.go
Normal file
32
cmd/energy/energy.go
Normal file
@ -0,0 +1,32 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/energye/energy/cmd"
|
||||
"github.com/jessevdk/go-flags"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
wd, _ := os.Getwd()
|
||||
commandConfig := &cmd.CommandConfig{}
|
||||
parser := flags.NewParser(commandConfig, flags.HelpFlag|flags.PassDoubleDash)
|
||||
if len(os.Args) < 2 {
|
||||
parser.WriteHelp(os.Stdout)
|
||||
os.Exit(1)
|
||||
}
|
||||
if ret, err := parser.ParseArgs(os.Args[1:]); err != nil {
|
||||
fmt.Fprint(os.Stderr, err.Error()+"\n")
|
||||
os.Exit(1)
|
||||
} else {
|
||||
fmt.Println(ret)
|
||||
fmt.Println(commandConfig.Install.Path)
|
||||
fmt.Println(parser.Active.Name)
|
||||
switch parser.Active.Name {
|
||||
case "install":
|
||||
cmd.CmdInstall(wd, commandConfig.Install)
|
||||
case "package":
|
||||
cmd.CmdPackage(wd, commandConfig.Package)
|
||||
}
|
||||
}
|
||||
}
|
7
cmd/install.go
Normal file
7
cmd/install.go
Normal file
@ -0,0 +1,7 @@
|
||||
package cmd
|
||||
|
||||
import "fmt"
|
||||
|
||||
func CmdInstall(wd string, install Install) {
|
||||
fmt.Println("开始安装CEF和Energy依赖")
|
||||
}
|
5
cmd/package.go
Normal file
5
cmd/package.go
Normal file
@ -0,0 +1,5 @@
|
||||
package cmd
|
||||
|
||||
func CmdPackage(wd string, pkg Package) {
|
||||
|
||||
}
|
7
go.mod
7
go.mod
@ -2,4 +2,9 @@ module github.com/energye/energy
|
||||
|
||||
go 1.18
|
||||
|
||||
require github.com/energye/golcl v0.0.0-20221024100207-844863c6a85e
|
||||
require (
|
||||
github.com/energye/golcl v0.0.0-20221024100207-844863c6a85e
|
||||
github.com/jessevdk/go-flags v1.5.0
|
||||
)
|
||||
|
||||
require golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 // indirect
|
||||
|
4
go.sum
4
go.sum
@ -1,2 +1,6 @@
|
||||
github.com/energye/golcl v0.0.0-20221024100207-844863c6a85e h1:GQW9Q6k1hwQgYw9wHKi+dcthWnZWDBrtyKBwrqCQn9M=
|
||||
github.com/energye/golcl v0.0.0-20221024100207-844863c6a85e/go.mod h1:8JYrNlYBZ+XbHA99DUWvj5CqIp8txgYvMjL7ipAtLDE=
|
||||
github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc=
|
||||
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
|
||||
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 h1:EZ2mChiOa8udjfp6rRmswTbtZN/QzUQp4ptM4rnjHvc=
|
||||
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
|
Loading…
Reference in New Issue
Block a user