Custom output directory
This commit is contained in:
parent
46f994e190
commit
56e4e4218a
|
@ -27,6 +27,7 @@ func main() {
|
||||||
ghOrganization := parser.String("o", "org", &argparse.Options{Required: false, Help: "Github Organization name", Default: "OpenFest"})
|
ghOrganization := parser.String("o", "org", &argparse.Options{Required: false, Help: "Github Organization name", Default: "OpenFest"})
|
||||||
authToken := parser.String("a", "authtoken", &argparse.Options{Required: false, Help: "Github Auth token", Default: AuthToken})
|
authToken := parser.String("a", "authtoken", &argparse.Options{Required: false, Help: "Github Auth token", Default: AuthToken})
|
||||||
quiet := parser.Flag("q", "quiet", &argparse.Options{Required: false, Help: "Skip output to stdout", Default: false})
|
quiet := parser.Flag("q", "quiet", &argparse.Options{Required: false, Help: "Skip output to stdout", Default: false})
|
||||||
|
keysDir := parser.String("d", "directory", &argparse.Options{Required: false, Help: "Path where to store the key files", Default: "./"})
|
||||||
|
|
||||||
// Parse input
|
// Parse input
|
||||||
err := parser.Parse(os.Args)
|
err := parser.Parse(os.Args)
|
||||||
|
@ -35,6 +36,17 @@ func main() {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fi, err := os.Lstat(*keysDir)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(*keysDir, ": target directory error :", err)
|
||||||
|
os.Exit(1)
|
||||||
|
} else {
|
||||||
|
if fi.Mode().IsDir() == false {
|
||||||
|
fmt.Println(*keysDir, ": target directory error : not a directory - ", fi.Mode())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ts := oauth2.StaticTokenSource(
|
ts := oauth2.StaticTokenSource(
|
||||||
&oauth2.Token{AccessToken: *authToken},
|
&oauth2.Token{AccessToken: *authToken},
|
||||||
|
@ -141,7 +153,8 @@ func main() {
|
||||||
nextPage = rsp.NextPage
|
nextPage = rsp.NextPage
|
||||||
}
|
}
|
||||||
|
|
||||||
err := ioutil.WriteFile(*user+".key", sshKeys.Bytes(), 0444)
|
fmt.Println("Writing to", *keysDir + *user+".key")
|
||||||
|
err := ioutil.WriteFile(*keysDir + "/" + *user+".key", sshKeys.Bytes(), 0444)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Errorf(*user+".key error %v", err)
|
fmt.Errorf(*user+".key error %v", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue