-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflags.go
61 lines (50 loc) · 1.67 KB
/
flags.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
package main
import (
"flag"
"fmt"
"os"
)
type Flags struct {
WADFilename string
printWADMusicInfo bool
printWADMapsInfo bool
dumpLumpsInfo string
dumpWADMusicInfo string
dumpWADMapsInfo string
exportMusic string
exportSprites string
}
func (f *Flags) parseFlags() {
printWADMusicInfo := flag.Bool("musicinfo", false, "Print WAD's music info via console")
printWADMapsInfo := flag.Bool("mapsinfo", false, "Print WAD's maps info via console")
dumpLumpsInfo := flag.String("lumpsinfo-dump", "", "Dump WAD's lumps info to file")
dumpWADMusicInfo := flag.String("musicinfo-dump", "", "Dump WAD's music info to file")
dumpWADMapsInfo := flag.String("mapsinfo-dump", "", "Dump WAD's maps info to file")
exportMusic := flag.String("music-export", "", "Export WAD's music to folder")
exportSprites := flag.String("sprite-export", "", "Export WAD's sprites to folder")
flag.Parse()
f.printWADMusicInfo = *printWADMusicInfo
f.printWADMapsInfo = *printWADMapsInfo
f.dumpLumpsInfo = *dumpLumpsInfo
f.dumpWADMusicInfo = *dumpWADMusicInfo
f.dumpWADMapsInfo = *dumpWADMapsInfo
f.exportMusic = *exportMusic
f.exportSprites = *exportSprites
flagTail := flag.Args()
f.parseWADFilename(flagTail)
}
func (f *Flags) parseWADFilename(flagTail []string) {
if len(flagTail) < 1 {
fmt.Println("[Error] getWADFilenameFromFlag: No WAD filename argument specified. Aborting extraction")
os.Exit(0)
}
filename := flag.Args()[0]
if filename == "" {
fmt.Println("[Error] getWADFilenameFromFlag: No WAD filename argument specified. Aborting extraction")
os.Exit(0)
}
f.WADFilename = filename
}
func (f *Flags) printFlags() {
fmt.Printf("%+v\n", f)
}