mirrored from https://git.sr.ht/~ancarda/tls-redirector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.go
45 lines (39 loc) · 1.29 KB
/
cli.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"fmt"
"io"
)
const (
exitSuccess = 0
exitFailure = 1
)
func handleCliArgs(w io.Writer, args []string, hasSocketActivation bool) int {
switch args[1] {
case "--version":
fmt.Fprintln(w, "tls redirector", version)
case "--help":
fmt.Fprintln(w, "Usage:", args[0], "[OPTION]")
fmt.Fprintln(w, "A tiny service for port 80 that rewrites URLs to HTTPS.")
fmt.Fprintln(w, "")
if hasSocketActivation {
fmt.Fprintln(w, "Compiled with support for systemd socket activation.")
} else {
fmt.Fprintln(w, "Compiled without support for systemd socket activation.")
}
fmt.Fprintln(w, "")
fmt.Fprintln(w, "Options")
fmt.Fprintln(w, " --help display this help and exit")
fmt.Fprintln(w, " --version output version information and exit")
fmt.Fprintln(w, "")
fmt.Fprintln(w, "Environmental Variables")
fmt.Fprintln(w, " PORT - TCP/IP port number to listen on.")
fmt.Fprintln(w, " ACME_CHALLENGE_DIR - Directory to serve at", acmeChallengeURLPrefix)
fmt.Fprintln(w, "")
fmt.Fprintln(w, "For more help, please refer to the README. Available online:")
fmt.Fprintln(w, " https://git.sr.ht/~ancarda/tls-redirector/tree/master/README.md")
default:
fmt.Fprintln(w, "unrecognized:", args[1])
return exitFailure
}
return exitSuccess
}