-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
45 lines (41 loc) · 1.05 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
package main
import (
"flag"
"fmt"
"log"
"os"
"path"
"path/filepath"
"strings"
"github.com/swim-services/swim_porter/port"
"github.com/swim-services/swim_porter/port/porterror"
)
func main() {
input := flag.String("i", "", "input pack")
output := flag.String("o", ".", "output path")
showCredits := flag.Bool("show-credits", false, "show credits")
skyboxOverride := flag.String("skybox-override", "", "skybox override")
flag.Parse()
if *input == "" {
flag.Usage()
os.Exit(-1)
}
dat, err := os.ReadFile(*input)
if err != nil {
log.Fatalln(err)
}
name := filepath.Base(*input)
nameNoExt := name[:strings.LastIndex(name, path.Ext(name))]
out, err := port.Port(dat, nameNoExt, port.PortOptions{ShowCredits: *showCredits, SkyboxOverride: *skyboxOverride})
if err != nil {
log.Println(err.Error())
if portError, ok := err.(*porterror.PortError); ok {
fmt.Println(portError.StackTrace())
}
os.Exit(-1)
}
outFile := (*output) + "/" + nameNoExt + ".mcpack"
if err := os.WriteFile(outFile, out, 0644); err != nil {
log.Fatalln(err)
}
}