···7373$ git-pages-cli https://example.org --server grebedoc.dev --password xyz --upload-dir ...
7474```
75757676+### Forge authorization
7777+7878+Uploading a directory to a site on a wildcard domain (e.g. `https://<owner>.grebedoc.dev/<repo>`) requires the use of an access token with push permissions for the corresponding repository (`https://codeberg.org/<owner>/<repo>.git` in this case).
7979+8080+To create such an access token on Forgejo:
8181+1. Open _Settings_ > _Applications_ > _Access tokens_.
8282+1. Expand _Select permissions_, pick _Read and write_ under _repository_.
8383+1. Set _Token name_ to something informative (e.g. "git-pages publishing").
8484+1. Click _Generate token_.
8585+1. The token will appear in a notification (a long string of hexadecimal numbers all on its own).
8686+8787+To deploy using an access token:
8888+8989+```console
9090+$ git-pages-cli https://username.grebedoc.dev --token <token> --upload-dir ...
9191+```
9292+9393+**Keep the access token safe and secure!** Anyone who has it will be able to change the data in any of your repositories.
9494+76957796Advanced usage
7897--------------
+13-2
main.go
···1818)
19192020var passwordFlag = pflag.String("password", "", "password for DNS challenge authorization")
2121+var tokenFlag = pflag.String("token", "", "token for forge authorization")
2122var challengeFlag = pflag.Bool("challenge", false, "compute DNS challenge entry from password (output zone file record)")
2223var challengeBareFlag = pflag.Bool("challenge-bare", false, "compute DNS challenge entry from password (output bare TXT value)")
2324var uploadGitFlag = pflag.String("upload-git", "", "replace site with contents of specified git repository")
···103104 return
104105}
105106107107+const usageExitCode = 125
108108+106109func main() {
107110 pflag.Parse()
108111 if !singleOperation() || (!*versionFlag && len(pflag.Args()) != 1) {
···110113 "Usage: %s <site-url> [--challenge|--upload-git url|--upload-dir path|--delete]\n",
111114 os.Args[0],
112115 )
113113- os.Exit(125)
116116+ os.Exit(usageExitCode)
114117 }
115118116119 if *versionFlag {
···118121 os.Exit(0)
119122 }
120123124124+ if *passwordFlag != "" && *tokenFlag != "" {
125125+ fmt.Fprintf(os.Stderr, "--password and --token are mutually exclusive")
126126+ os.Exit(usageExitCode)
127127+ }
128128+121129 var err error
122130 siteURL, err := url.Parse(pflag.Args()[0])
123131 if err != nil {
···203211 panic("no operation chosen")
204212 }
205213 request.Header.Add("User-Agent", versionInfo())
206206- if *passwordFlag != "" {
214214+ switch {
215215+ case *passwordFlag != "":
207216 request.Header.Add("Authorization", fmt.Sprintf("Pages %s", *passwordFlag))
217217+ case *tokenFlag != "":
218218+ request.Header.Add("Forge-Authorization", fmt.Sprintf("token %s", *tokenFlag))
208219 }
209220 if *serverFlag != "" {
210221 // Send the request to `--server` host, but set the `Host:` header to the site host.