diff --git a/README.md b/README.md index e77db1e..4d6c168 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,20 @@ This is a simple tool for updating of [Neversink's loot filter](https://github.c * In case you wish to use different style of filters: * Create a shortcut of exe file. * Right click it and select "Properties". - * In "Shortcut" section, append desired style name behind "Target". - Currently, valid choices are: `blue`, `purple`, `slick` and `streamsound`. + * In "Shortcut" section, append `--style`, followed by desired style name behind "Target". + Currently, valid choices are: `blue`, `purple`, `slick` and `streamsound`. The result + should look, for example, like: `C:\neversink-filter-updater.exe --style blue` + +If you don't mind using command line, here is the usage: + +```bash +Usage: + -help + Prints help. + -style string + Style of filters. Can be one of: blue, purple, slick, streamsound. + -version + Prints version. +``` This program was tested on 64-bit Windows 10. \ No newline at end of file diff --git a/main.go b/main.go index 1e16f60..24dd739 100644 --- a/main.go +++ b/main.go @@ -23,13 +23,29 @@ var poePath = filepath.Join(os.Getenv("USERPROFILE"), "Documents/My Games/Path o var dotFilePath = filepath.Join(poePath, ".neversink-updater") func main() { - var filterType string + filterStyle := flag.String( + "style", + "", + "Style of filters. Can be one of: blue, purple, slick, streamsound.") + helpPtr := flag.Bool("help", false, "Prints help.") + versionPtr := flag.Bool("version", false, "Prints version.") - if len(os.Args) > 1 { - filterType = os.Args[1] + flag.Usage = func() { + fmt.Fprintln(os.Stderr, "Usage:") + flag.PrintDefaults() } - parseFlags() + flag.Parse() + + if *versionPtr { + fmt.Fprintf(os.Stdout, version) + os.Exit(0) + } + + if *helpPtr { + flag.PrintDefaults() + os.Exit(0) + } if err := checkPoeDir(); err != nil { exit(1, err.Error()) @@ -54,12 +70,12 @@ func main() { } tmpArchivePath := createTmpArchive(zipFile) - unzippedFileCount := unzipArchive(tmpArchivePath, filterType) + unzippedFileCount := unzipArchive(tmpArchivePath, *filterStyle) if unzippedFileCount > 0 { fmt.Fprintf(os.Stdout, "%d files were unzipped.\n", unzippedFileCount) } else { - exit(1, fmt.Sprintf("No files were unzipped. Is \"%s\" correct filter type?", filterType)) + exit(1, fmt.Sprintf("No files were unzipped. Is \"%s\" correct filter style?", *filterStyle)) } writeToDotfile(*release.TagName) @@ -73,28 +89,6 @@ func main() { exit(0, "") } -func parseFlags() { - helpPtr := flag.Bool("help", false, "Prints help") - versionPtr := flag.Bool("version", false, "Prints version") - - flag.Usage = func() { - fmt.Fprintln(os.Stderr, "Usage:") - flag.PrintDefaults() - } - - flag.Parse() - - if *versionPtr { - fmt.Fprintf(os.Stdout, version) - os.Exit(0) - } - - if *helpPtr { - flag.PrintDefaults() - os.Exit(0) - } -} - func exit(code int, message string) { output := os.Stdout