animeic-cd před 1 rokem
rodič
revize
192719b7cc
3 změnil soubory, kde provedl 38 přidání a 6 odebrání
  1. 5 1
      go.mod
  2. 5 0
      go.sum
  3. 28 5
      main.go

+ 5 - 1
go.mod

@@ -2,9 +2,13 @@ module app-uploader
 
 go 1.21.3
 
-require github.com/huaweicloud/huaweicloud-sdk-go-obs v3.23.9+incompatible
+require (
+	github.com/huaweicloud/huaweicloud-sdk-go-obs v3.23.9+incompatible
+	github.com/jessevdk/go-flags v1.5.0
+)
 
 require (
 	golang.org/x/net v0.19.0 // indirect
+	golang.org/x/sys v0.15.0 // indirect
 	golang.org/x/text v0.14.0 // indirect
 )

+ 5 - 0
go.sum

@@ -1,6 +1,11 @@
 github.com/huaweicloud/huaweicloud-sdk-go-obs v3.23.9+incompatible h1:zUhCrGMMpJxZGAB30GbQzluDhQuPENxRQfxss7KlpKU=
 github.com/huaweicloud/huaweicloud-sdk-go-obs v3.23.9+incompatible/go.mod h1:l7VUhRbTKCzdOacdT4oWCwATKyvZqUOlOqr0Ous3k4s=
+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/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
 golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
+golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
+golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
 golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
 golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=

+ 28 - 5
main.go

@@ -4,16 +4,43 @@ import (
 	"app-uploader/huawei"
 	"app-uploader/utils"
 	"fmt"
-	"os"
+	"path/filepath"
 	"runtime"
 	"strconv"
 	"strings"
+
+	"github.com/jessevdk/go-flags"
 )
 
+var GAppOption = &AppOption{}
+
+// short只能是一个字符
+type AppOption struct {
+	Unzip string `short:"d" long:"unzip" description:"unzip file"`
+}
+
+func (o *AppOption) Parse() {
+	_, err := flags.NewParser(o, flags.Default|flags.IgnoreUnknown).Parse()
+	fmt.Println(err)
+}
+
 func main() {
 	// 读取package.json版本数据
 	// 复制app.json文件和logo文件
 	// 读取配置
+	// 解压工具 app-uploader.exe -d output/queenter-v1.1.2-amd64-windows.zip
+	// !压缩后的文件在windows上用软件打开有问题,但在linux上解压或者unzip正常
+	// utils.Unzip(zipPath,filepath.Base(zipFile),nil)
+	GAppOption.Parse()
+	if len(GAppOption.Unzip) > 0 {
+		dest := fmt.Sprintf("output/%s", filepath.Base(GAppOption.Unzip))
+		err := utils.Unzip(GAppOption.Unzip, dest, nil)
+		if err != nil {
+			fmt.Println("unzip err:", err)
+			return
+		}
+		return
+	}
 	appConf, err := utils.ReadAppConfig()
 	if err != nil {
 		fmt.Println("读取配置文件错误")
@@ -106,8 +133,4 @@ func main() {
 		return
 	}
 	fmt.Println("上传成功")
-	// !压缩后的文件在windows上用软件打开有问题,但在linux上解压或者unzip正常
-	// utils.Unzip(zipPath,filepath.Base(zipFile),nil)
-	os.Remove(zipPath)
-
 }