[mirror] Command-line application for uploading a site to a git-pages server

Add `--challenge-bare`, for use in scripts.

+13 -3
+2
README.md
··· 35 35 ```console 36 36 $ git-pages-cli https://mycoolweb.site --password xyz --challenge 37 37 _git-pages-challenge.mycoolweb.site. 3600 IN TXT "317716dee4379c167e8b5ce9df38eb880e043e5a842d160fe8d5bb408ee0c191" 38 + $ git-pages-cli https://mycoolweb.site --password xyz --challenge-bare 39 + 317716dee4379c167e8b5ce9df38eb880e043e5a842d160fe8d5bb408ee0c191 38 40 ``` 39 41 40 42 To deploy a site from a git repository available on the internet (`--password` may be omitted if the repository is allowlisted via DNS):
+11 -3
main.go
··· 16 16 ) 17 17 18 18 var passwordFlag = pflag.String("password", "", "password for DNS challenge authorization") 19 - var challengeFlag = pflag.Bool("challenge", false, "compute DNS challenge entry from password") 19 + var challengeFlag = pflag.Bool("challenge", false, "compute DNS challenge entry from password (output zone file record)") 20 + var challengeBareFlag = pflag.Bool("challenge-bare", false, "compute DNS challenge entry from password (output bare TXT value)") 20 21 var uploadGitFlag = pflag.String("upload-git", "", "replace site with contents of specified git repository") 21 22 var uploadDirFlag = pflag.String("upload-dir", "", "replace site with contents of specified directory") 22 23 var deleteFlag = pflag.Bool("delete", false, "delete site") ··· 25 26 func singleOperation() bool { 26 27 operations := 0 27 28 if *challengeFlag { 29 + operations++ 30 + } 31 + if *challengeBareFlag { 28 32 operations++ 29 33 } 30 34 if *uploadDirFlag != "" { ··· 97 101 98 102 var request *http.Request 99 103 switch { 100 - case *challengeFlag: 104 + case *challengeFlag || *challengeBareFlag: 101 105 if *passwordFlag == "" { 102 106 fmt.Fprintf(os.Stderr, "error: no --password option specified\n") 103 107 os.Exit(1) 104 108 } 105 109 106 110 challenge := sha256.Sum256(fmt.Appendf(nil, "%s %s", siteUrl.Hostname(), *passwordFlag)) 107 - fmt.Fprintf(os.Stdout, "_git-pages-challenge.%s. 3600 IN TXT \"%x\"\n", siteUrl.Hostname(), challenge) 111 + if *challengeBareFlag { 112 + fmt.Fprintf(os.Stdout, "%x\n", challenge) 113 + } else { 114 + fmt.Fprintf(os.Stdout, "_git-pages-challenge.%s. 3600 IN TXT \"%x\"\n", siteUrl.Hostname(), challenge) 115 + } 108 116 os.Exit(0) 109 117 110 118 case *uploadGitFlag != "":