U: upgrade command-line tool

This commit is contained in:
杨红岩 2023-08-21 12:22:08 +08:00
parent d1ee2b83a1
commit 5759f31b05
4 changed files with 27 additions and 29 deletions

View File

@ -1,23 +1,8 @@
# Energy 命令行工具
## 自动配置开发环境
## 使用方式
> 一、使用预编译
>
> 下载地址
>> [energy_cmd_windows32](http://energy.yanghy.cn/download/energy_cmd_windows32.zip)
>>
>> [energy_cmd_windows64](http://energy.yanghy.cn/download/energy_cmd_windows64.zip)
>>
>> [energy_cmd_macosx64](http://energy.yanghy.cn/download/energy_cmd_macosx64.zip)
>>
>> [energy_cmd_linux64](http://energy.yanghy.cn/download/energy_cmd_linux64.zip)
>>
>> 配置到环境变量 或 直接在命令行中执行
>
> 二、自行编译
>
> 需要安装[Golang](https://golang.google.cn/dl/)环境
>>go get -u github.com/energye/energy
>> go get -u github.com/energye/energy
>>
>> 进入 cmd/energy 目录
>>
@ -39,11 +24,7 @@
| version | 可选参数, 版本号v1.1.0, 默认最新版本latest |
>示例
>> 1. energy install
>> 1. `energy install .`
>>
>> 2. energy install --path=/app/energyFramework --version=v1.1.0
>>
----
### Public License
[![license](https://img.shields.io/github/license/energye/energy.svg?logo=git&logoColor=green)](http://www.apache.org/licenses/LICENSE-2.0)
>> 2. `energy install --path=/app/energyFramework -v x.x.x .`
>>

View File

@ -2,18 +2,30 @@ SET CGO_ENABLED=0
set GOARCH=386
set GOOS=windows
go build -ldflags "-s -w" -o energy-32.exe energy.go
go build -ldflags "-s -w" -o energy-win-32.exe energy.go
set GOARCH=amd64
set GOOS=windows
go build -ldflags "-s -w" -o energy-64.exe energy.go
go build -ldflags "-s -w" -o energy-win-64.exe energy.go
set GOARCH=arm64
set GOOS=windows
go build -ldflags "-s -w" -o energy-winarm-64.exe energy.go
set GOARCH=amd64
set GOOS=darwin
go build -ldflags "-s -w" -o energy-darwin-64 energy.go
set GOARCH=arm64
set GOOS=darwin
go build -ldflags "-s -w" -o energy-darwinarm-64 energy.go
set GOARCH=amd64
set GOOS=linux
go build -ldflags "-s -w" -o energy-linux-64 energy.go
set GOARCH=arm64
set GOOS=linux
go build -ldflags "-s -w" -o energy-linuxarm-64 energy.go
pause

View File

@ -31,7 +31,7 @@ type Install struct {
Path string `short:"p" long:"path" description:"Installation directory Default current directory"`
Version string `short:"v" long:"version" description:"Specifying a version number"`
Name string `short:"n" long:"name" description:"Name of the frame after installation" default:"EnergyFramework"`
Download string `short:"d" long:"download" description:"Download Source, gitee or github, Default gitee" default:"gitee"`
Download string `short:"d" long:"download" description:"Download Source, 0:gitee or 1:github, Default empty" default:""`
CEF string `short:"c" long:"cef" description:"Install system supports CEF version, provide 4 options, default empty. default, windows7, gtk2, flash" default:""`
}

View File

@ -203,8 +203,13 @@ func runInstall(c *CommandConfig) error {
println("error: cef module", cefModuleName, "is not configured in the current version")
os.Exit(1)
}
var replaceSource = func(url, source string, sourceSelect int) string {
// 下载源选择
var replaceSource = func(url, source string, sourceSelect int, module string) string {
s := strings.Split(source, ",")
// liblcl 如果自己选择下载源
if module == "liblcl" && c.Install.Download != "" {
sourceSelect = ToInt(c.Install.Download)
}
if len(s) > sourceSelect {
return strings.ReplaceAll(url, "{source}", s[sourceSelect])
}
@ -217,7 +222,7 @@ func runInstall(c *CommandConfig) error {
// 当前模块版本支持系统,如果支持返回下载地址
libCEFOS, isSupport := cefOS(cefModule)
downloadCefURL := ToString(cefModule["downloadUrl"])
downloadCefURL = replaceSource(downloadCefURL, ToString(cefModule["downloadSource"]), ToInt(cefModule["downloadSourceSelect"]))
downloadCefURL = replaceSource(downloadCefURL, ToString(cefModule["downloadSource"]), ToInt(cefModule["downloadSourceSelect"]), "cef")
downloadCefURL = strings.ReplaceAll(downloadCefURL, "{version}", cefVersion)
downloadCefURL = strings.ReplaceAll(downloadCefURL, "{OSARCH}", libCEFOS)
downloads[cefKey] = &downloadInfo{isSupport: isSupport, fileName: urlName(downloadCefURL), downloadPath: filepath.Join(c.Install.Path, frameworkCache, urlName(downloadCefURL)), frameworkPath: installPathName, url: downloadCefURL}
@ -229,7 +234,7 @@ func runInstall(c *CommandConfig) error {
if liblclModule != nil {
libEnergyOS, isSupport := liblclOS(cef, liblclVersion, liblclModule)
downloadEnergyURL := ToString(liblclModule["downloadUrl"])
downloadEnergyURL = replaceSource(downloadEnergyURL, ToString(liblclModule["downloadSource"]), ToInt(liblclModule["downloadSourceSelect"]))
downloadEnergyURL = replaceSource(downloadEnergyURL, ToString(liblclModule["downloadSource"]), ToInt(liblclModule["downloadSourceSelect"]), "liblcl")
module := ToString(liblclModule["module"])
downloadEnergyURL = strings.ReplaceAll(downloadEnergyURL, "{version}", liblclVersion)
downloadEnergyURL = strings.ReplaceAll(downloadEnergyURL, "{module}", module)