56 lines
1.3 KiB
Go
56 lines
1.3 KiB
Go
|
package config
|
||
|
|
||
|
import (
|
||
|
"os"
|
||
|
"strings"
|
||
|
|
||
|
"git.velvettear.de/velvettear/loggo"
|
||
|
)
|
||
|
|
||
|
var Directory string
|
||
|
var FramesToKeep []string
|
||
|
|
||
|
// check program arguments and set variables accordingly
|
||
|
func CheckArguments() {
|
||
|
argsCount := len(os.Args)
|
||
|
var framesToKeep []string
|
||
|
for index := 0; index < argsCount; index++ {
|
||
|
switch os.Args[index] {
|
||
|
case "-d":
|
||
|
fallthrough
|
||
|
case "--debug":
|
||
|
loggo.SetLogLevel(loggo.DebugLevel)
|
||
|
case "-f":
|
||
|
fallthrough
|
||
|
case "--frames":
|
||
|
framesToKeep = strings.Split(os.Args[index+1], ",")
|
||
|
case "-h":
|
||
|
fallthrough
|
||
|
case "--help":
|
||
|
printHelp()
|
||
|
}
|
||
|
}
|
||
|
Directory = os.Args[len(os.Args)-1]
|
||
|
if len(framesToKeep) == 0 {
|
||
|
FramesToKeep = []string{"APIC", "TALB", "TCON", "TDAT", "TDRC", "TIT2", "TPOS", "TPE1", "TPE2", "TRCK"}
|
||
|
} else {
|
||
|
for _, frame := range framesToKeep {
|
||
|
FramesToKeep = append(FramesToKeep, strings.ToUpper(strings.TrimSpace(frame)))
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// print the help
|
||
|
func printHelp() {
|
||
|
loggo.SetLogFormat("# $MESSAGE$")
|
||
|
loggo.Info("tagcleaner")
|
||
|
loggo.Info("Daniel Sommer <daniel.sommer@velvettear.de>")
|
||
|
loggo.Info("\n")
|
||
|
loggo.Info("usage:\ttagcleaner [options] <directory>")
|
||
|
loggo.Info("\n")
|
||
|
loggo.Info("options:")
|
||
|
loggo.Info("\t-d | --debug\tenable debug mode")
|
||
|
loggo.Info("\t-f | --frames\tframes to keep")
|
||
|
os.Exit(0)
|
||
|
}
|