mirror of
https://gitee.com/energye/energy.git
synced 2024-12-14 09:21:14 +08:00
upgrade: energy command line
This commit is contained in:
parent
1ed376f311
commit
f214c0ca5f
@ -1,3 +1,11 @@
|
||||
//----------------------------------------
|
||||
//
|
||||
// Copyright © yanghy. All Rights Reserved.
|
||||
//
|
||||
// Licensed under GNU General Public License v3.0
|
||||
//
|
||||
//----------------------------------------
|
||||
|
||||
package cmd
|
||||
|
||||
type CommandConfig struct {
|
||||
|
@ -1,3 +1,11 @@
|
||||
//----------------------------------------
|
||||
//
|
||||
// Copyright © yanghy. All Rights Reserved.
|
||||
//
|
||||
// Licensed under GNU General Public License v3.0
|
||||
//
|
||||
//----------------------------------------
|
||||
|
||||
package cmd
|
||||
|
||||
const (
|
||||
|
19
cmd/energy/build.bat
Normal file
19
cmd/energy/build.bat
Normal file
@ -0,0 +1,19 @@
|
||||
SET CGO_ENABLED=1
|
||||
|
||||
set GOARCH=386
|
||||
set GOOS=windows
|
||||
go build -o energy-32.exe energy.go
|
||||
|
||||
set GOARCH=amd64
|
||||
set GOOS=windows
|
||||
go build -o energy-64.exe energy.go
|
||||
|
||||
set GOARCH=amd64
|
||||
set GOOS=darwin
|
||||
go build -o energy-darwin-64 energy.go
|
||||
|
||||
set GOARCH=amd64
|
||||
set GOOS=linux
|
||||
go build -o energy-linux-64 energy.go
|
||||
|
||||
pause
|
@ -1,3 +1,11 @@
|
||||
//----------------------------------------
|
||||
//
|
||||
// Copyright © yanghy. All Rights Reserved.
|
||||
//
|
||||
// Licensed under GNU General Public License v3.0
|
||||
//
|
||||
//----------------------------------------
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
@ -27,9 +35,9 @@ func main() {
|
||||
os.Exit(1)
|
||||
} else {
|
||||
switch parser.Active.Name {
|
||||
case "install":
|
||||
case "install", "i":
|
||||
cc.Index = 1
|
||||
case "package":
|
||||
case "package", "p":
|
||||
cc.Index = 2
|
||||
case "version", "v":
|
||||
cc.Index = 3
|
||||
|
@ -1,3 +1,11 @@
|
||||
//----------------------------------------
|
||||
//
|
||||
// Copyright © yanghy. All Rights Reserved.
|
||||
//
|
||||
// Licensed under GNU General Public License v3.0
|
||||
//
|
||||
//----------------------------------------
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
|
@ -1,3 +1,11 @@
|
||||
//----------------------------------------
|
||||
//
|
||||
// Copyright © yanghy. All Rights Reserved.
|
||||
//
|
||||
// Licensed under GNU General Public License v3.0
|
||||
//
|
||||
//----------------------------------------
|
||||
|
||||
package cmd
|
||||
|
||||
import "fmt"
|
||||
|
@ -1,3 +1,11 @@
|
||||
//----------------------------------------
|
||||
//
|
||||
// Copyright © yanghy. All Rights Reserved.
|
||||
//
|
||||
// Licensed under GNU General Public License v3.0
|
||||
//
|
||||
//----------------------------------------
|
||||
|
||||
package progressbar
|
||||
|
||||
import (
|
||||
|
@ -1,3 +1,11 @@
|
||||
//----------------------------------------
|
||||
//
|
||||
// Copyright © yanghy. All Rights Reserved.
|
||||
//
|
||||
// Licensed under GNU General Public License v3.0
|
||||
//
|
||||
//----------------------------------------
|
||||
|
||||
package progressbar
|
||||
|
||||
type BarColor struct {
|
||||
|
@ -1,3 +1,11 @@
|
||||
//----------------------------------------
|
||||
//
|
||||
// Copyright © yanghy. All Rights Reserved.
|
||||
//
|
||||
// Licensed under GNU General Public License v3.0
|
||||
//
|
||||
//----------------------------------------
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
@ -5,6 +13,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"sort"
|
||||
)
|
||||
|
||||
var CmdVersion = &Command{
|
||||
@ -33,14 +42,22 @@ func runVersion(c *CommandConfig) error {
|
||||
os.Exit(1)
|
||||
}
|
||||
if versionList, ok := edv["versionList"].(map[string]interface{}); ok {
|
||||
for version, fver := range versionList {
|
||||
var ver = fver.(map[string]interface{})
|
||||
var keys []string
|
||||
for k, _ := range versionList {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
println("Latest:", edv["latest"].(string))
|
||||
println("Version list")
|
||||
for i := len(keys) - 1; i >= 0; i-- {
|
||||
var version = keys[i]
|
||||
var ver = versionList[version].(map[string]interface{})
|
||||
if c.Version.All {
|
||||
println(" ", version, fmt.Sprintf(`
|
||||
CEF: %s
|
||||
ENERGY: %s`, ver["cef"].(string), ver["energy"].(string)))
|
||||
println(" ", version, fmt.Sprintf(`
|
||||
CEF: %s
|
||||
ENERGY: %s`, ver["cef"].(string), ver["energy"].(string)))
|
||||
} else {
|
||||
println(" ", version)
|
||||
println(" ", version)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user