2022-12-07 15:50:59 +08:00
|
|
|
//----------------------------------------
|
|
|
|
//
|
|
|
|
// Copyright © yanghy. All Rights Reserved.
|
|
|
|
//
|
2023-02-19 23:21:47 +08:00
|
|
|
// Licensed under Apache License Version 2.0, January 2004
|
|
|
|
//
|
|
|
|
// https://www.apache.org/licenses/LICENSE-2.0
|
2022-12-07 15:50:59 +08:00
|
|
|
//
|
|
|
|
//----------------------------------------
|
|
|
|
|
2023-09-03 18:40:44 +08:00
|
|
|
package command
|
2022-11-09 11:50:59 +08:00
|
|
|
|
2023-09-09 18:50:50 +08:00
|
|
|
type OS string
|
|
|
|
type Arch string
|
|
|
|
|
2023-09-03 18:40:44 +08:00
|
|
|
type Config struct {
|
2023-09-11 15:28:02 +08:00
|
|
|
Index int
|
|
|
|
Wd string
|
|
|
|
EnergyCfg EnergyConfig
|
|
|
|
Install Install `command:"install" description:"install energy development dependency environment"`
|
|
|
|
Package Package `command:"package" description:"energy application production and installation package"`
|
|
|
|
Version Version `command:"version" description:"list all release version numbers of energy"`
|
|
|
|
Setenv Setenv `command:"setenv" description:"set ENERGY_ HOME framework environment"`
|
|
|
|
Env Env `command:"env" description:"display ENERGY_ HOME framework environment directory"`
|
|
|
|
Init Init `command:"init" description:"initialize the energy application project"`
|
|
|
|
Build Build `command:"build" description:"building an energy project"`
|
2023-08-20 21:51:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type Command struct {
|
2023-09-03 18:40:44 +08:00
|
|
|
Run func(c *Config) error
|
2023-08-20 21:51:12 +08:00
|
|
|
UsageLine, Short, Long string
|
2022-11-09 11:50:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type Install struct {
|
2022-11-18 12:15:47 +08:00
|
|
|
Path string `short:"p" long:"path" description:"Installation directory Default current directory"`
|
|
|
|
Version string `short:"v" long:"version" description:"Specifying a version number"`
|
2023-09-05 17:01:33 +08:00
|
|
|
Name string `short:"n" long:"name" description:"Name of the framework directory after installation" default:"EnergyFramework"`
|
2023-08-21 12:22:08 +08:00
|
|
|
Download string `short:"d" long:"download" description:"Download Source, 0:gitee or 1:github, Default empty" default:""`
|
2023-09-09 18:50:50 +08:00
|
|
|
OS OS `long:"os" description:"Specify install OS: [windows, linux, darwin], default current system: os"`
|
|
|
|
Arch Arch `long:"arch" description:"Specify install ARCH: [386, amd64, arm64], Default current system: architecture"`
|
2023-09-09 20:16:40 +08:00
|
|
|
CEF string `long:"cef" description:"Install system supports CEF version, provide 4 options, default empty. default, windows7, gtk2, flash" default:""`
|
2023-09-12 11:01:19 +08:00
|
|
|
IGolang bool // 是否安装Golang
|
|
|
|
ICEF bool // 是否安装CEF
|
|
|
|
INSIS bool // 是否安装nsis
|
|
|
|
IUPX bool // 是否安装upx
|
|
|
|
I7za bool // 是否安装7za
|
2023-09-09 18:50:50 +08:00
|
|
|
IsSame bool // 安装的OS和Arch是否为当前系统架构, 默认当前系统架构
|
2022-11-09 11:50:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type Package struct {
|
2023-09-08 18:19:47 +08:00
|
|
|
Path string `short:"p" long:"path" description:"Project path, default current path. Can be configured in energy.json" default:""`
|
2023-09-08 15:11:39 +08:00
|
|
|
Clean bool `short:"c" long:"clean" description:"Clear configuration and regenerate the default configuration"`
|
2022-11-09 11:50:59 +08:00
|
|
|
}
|
2022-11-09 12:12:40 +08:00
|
|
|
|
2023-07-26 11:13:45 +08:00
|
|
|
type Env struct {
|
|
|
|
}
|
|
|
|
|
2023-07-21 13:01:05 +08:00
|
|
|
type Setenv struct {
|
|
|
|
Path string `short:"p" long:"path" description:"Energy framework dir"`
|
|
|
|
}
|
|
|
|
|
2022-11-18 12:56:27 +08:00
|
|
|
type Version struct {
|
|
|
|
All bool `short:"a" long:"all" description:"show all"`
|
|
|
|
}
|
|
|
|
|
2023-09-02 23:57:26 +08:00
|
|
|
type Init struct {
|
2023-09-03 22:00:35 +08:00
|
|
|
Name string `short:"n" long:"name" description:"Initialized project name"`
|
|
|
|
ResLoad string `short:"r" long:"resload" description:"Resource loading method, 1: HTTP, 2: Local Load, default 1 HTTP"`
|
|
|
|
IGo bool
|
|
|
|
INSIS bool
|
2023-09-11 17:41:30 +08:00
|
|
|
IUPX bool
|
2023-09-03 22:00:35 +08:00
|
|
|
IEnv bool
|
|
|
|
INpm bool
|
2022-11-09 12:12:40 +08:00
|
|
|
}
|
2023-08-18 18:20:52 +08:00
|
|
|
|
2023-08-20 21:51:12 +08:00
|
|
|
type Build struct {
|
2023-09-08 18:19:47 +08:00
|
|
|
Path string `short:"p" long:"path" description:"Project path, default current path. Can be configured in energy.json" default:""`
|
|
|
|
Upx bool `short:"u" long:"upx" description:"Set this parameter and install upx. Use upx to compress the execution file. windows"`
|
|
|
|
UpxFlag string `long:"upxFlag" description:"Upx command line parameters" default:""`
|
2023-09-14 16:14:36 +08:00
|
|
|
Gtk string `long:"gtk" description:"Compile on Linux, enable TempDll. gtk: gtk2 or gtk3" default:"gtk3"`
|
2023-09-14 15:26:48 +08:00
|
|
|
TempDll bool `short:"d" long:"dll" description:"Enable built-in liblcl build"`
|
2023-08-18 18:20:52 +08:00
|
|
|
}
|
2023-09-09 18:50:50 +08:00
|
|
|
|
2023-09-11 15:28:02 +08:00
|
|
|
type EnergyConfig struct {
|
2023-09-14 15:26:48 +08:00
|
|
|
Framework string `json:"framework"`
|
|
|
|
Version string `json:"version"`
|
|
|
|
Source DownloadSource `json:"source"`
|
2023-09-11 15:28:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type DownloadSource struct {
|
|
|
|
Golang string `json:"golang"`
|
|
|
|
CEF string `json:"cef"`
|
|
|
|
}
|
|
|
|
|
2023-09-09 18:50:50 +08:00
|
|
|
func (m OS) IsWindows() bool {
|
|
|
|
return m == "windows"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m OS) IsLinux() bool {
|
|
|
|
return m == "linux"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m OS) IsDarwin() bool {
|
|
|
|
return m == "darwin"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m Arch) Is386() bool {
|
|
|
|
return m == "386" || m == "32" // windows32
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m Arch) IsAMD64() bool {
|
|
|
|
return m == "amd64"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m Arch) IsARM64() bool {
|
|
|
|
return m == "arm64"
|
|
|
|
}
|