-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.go
64 lines (57 loc) · 1.27 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
*
* @Author evsio0n
* @Date 2024/10/31 下午5:10
* @Email <[email protected]>
*
*/
package main
import (
"github.com/Evsio0n/rsce-go/rsceUtil"
log2 "github.com/evsio0n/log"
"github.com/urfave/cli"
"os"
"sort"
)
var log *log2.Logger
const (
name = "rsce-go"
author = "evsio0n <[email protected]>"
version = "0.0.1"
description = "rsce-go is a tool for unpack or pack RSCE, aka rock chip resource image. \r\n" +
"\t using -u to unpack, using -p to pack.\r\n" +
"\t -u [filepath] unpack rockchip rsce image\r\n" +
"\t -p [filepath] [filepath] [filepath] pack all resource to rockchip rsce image\r\n"
)
func main() {
cmd := &cli.App{
Name: name,
Author: author,
Version: version,
Description: description,
Flags: []cli.Flag{
cli.StringFlag{
Name: "unpack,u",
Usage: "unpack rsce image",
},
cli.StringSliceFlag{
Name: "pack,p",
Usage: "pack rsce image",
},
},
Action: Handle,
}
sort.Sort(cli.FlagsByName(cmd.Flags))
err := cmd.Run(os.Args)
if err != nil {
log.Error(err.Error())
}
}
func Handle(c *cli.Context) {
if c.String("unpack") != "" {
RSCEUtil.UnPackRSCE(c.String("unpack"))
}
if len(c.StringSlice("pack")) > 0 {
RSCEUtil.GenerateRSCE(c.StringSlice("pack"), "./boot-second")
}
}