upgrade: energy command line

This commit is contained in:
杨红岩 2022-12-11 12:25:37 +08:00
parent 1ed376f311
commit f214c0ca5f
9 changed files with 100 additions and 8 deletions

View File

@ -1,3 +1,11 @@
//----------------------------------------
//
// Copyright © yanghy. All Rights Reserved.
//
// Licensed under GNU General Public License v3.0
//
//----------------------------------------
package cmd
type CommandConfig struct {

View File

@ -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
View 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

View File

@ -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

View File

@ -1,3 +1,11 @@
//----------------------------------------
//
// Copyright © yanghy. All Rights Reserved.
//
// Licensed under GNU General Public License v3.0
//
//----------------------------------------
package cmd
import (

View File

@ -1,3 +1,11 @@
//----------------------------------------
//
// Copyright © yanghy. All Rights Reserved.
//
// Licensed under GNU General Public License v3.0
//
//----------------------------------------
package cmd
import "fmt"

View File

@ -1,3 +1,11 @@
//----------------------------------------
//
// Copyright © yanghy. All Rights Reserved.
//
// Licensed under GNU General Public License v3.0
//
//----------------------------------------
package progressbar
import (

View File

@ -1,3 +1,11 @@
//----------------------------------------
//
// Copyright © yanghy. All Rights Reserved.
//
// Licensed under GNU General Public License v3.0
//
//----------------------------------------
package progressbar
type BarColor struct {

View File

@ -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)
}
}
}