package config import ( "os" "strconv" "strings" "git.velvettear.de/velvettear/loggo" ) var Directory string var FramesToKeep []string var Timeout int // 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 "-t": fallthrough case "--timeout": Timeout, _ = strconv.Atoi(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))) } } if Timeout <= 0 { Timeout = 30 } } // print the help func printHelp() { loggo.SetLogFormat("# $MESSAGE$") loggo.Info("tagcleaner") loggo.Info("Daniel Sommer ") loggo.Info("\n") loggo.Info("usage:\ttagcleaner [options] ") 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) }