]> Cypherpunks.ru repositories - gocheese.git/blobdiff - gocheese.go
Slightly more descriptive -auth option
[gocheese.git] / gocheese.go
index 155bf1a98b7aac482c4a3b83ddd6250a908516fe..a8f64910a94250fa5702749f36b05add4e2d3837 100644 (file)
@@ -4,8 +4,7 @@ Copyright (C) 2019 Sergey Matveev <stargrave@stargrave.org>
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+the Free Software Foundation, version 3 of the License.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -47,8 +46,7 @@ const (
 
        Warranty = `This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+the Free Software Foundation, version 3 of the License.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -65,7 +63,7 @@ var (
        norefreshURLPath = flag.String("norefresh", "/norefresh/", "Non-refreshing URL path")
        refreshURLPath   = flag.String("refresh", "/simple/", "Auto-refreshing URL path")
        pypiURL          = flag.String("pypi", "https://pypi.org/simple/", "Upstream PyPI URL")
-       auth             = flag.String("auth", "spam:foo", "login:password,...")
+       auth             = flag.String("auth", "passwd", "Path to file with login:password lines")
        fsck             = flag.Bool("fsck", false, "Check integrity of all packages")
        version          = flag.Bool("version", false, "Print version information")
        warranty         = flag.Bool("warranty", false, "Print warranty information")
@@ -427,7 +425,11 @@ func main() {
                }
                return
        }
-       for _, credentials := range strings.Split(*auth, ",") {
+       auth, err := ioutil.ReadFile(*auth)
+       if err != nil {
+               log.Fatal(err)
+       }
+       for _, credentials := range strings.Split(strings.TrimRight(string(auth), "\n"), "\n") {
                splitted := strings.Split(credentials, ":")
                if len(splitted) != 2 {
                        log.Fatal("Wrong auth format")