Add all of the flags

This commit is contained in:
Amolith 2021-12-25 08:12:17 -05:00
parent 5762f27a24
commit 6e530e2fde
No known key found for this signature in database
GPG key ID: 5548AD9930655715
3 changed files with 16 additions and 0 deletions

2
go.mod
View file

@ -1,3 +1,5 @@
module git.sr.ht/~amolith/go-webring
go 1.17
require github.com/spf13/pflag v1.0.5

2
go.sum Normal file
View file

@ -0,0 +1,2 @@
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=

12
main.go
View file

@ -5,6 +5,8 @@ import (
"fmt"
"os"
"strings"
flag "github.com/spf13/pflag"
)
type ring struct {
@ -12,7 +14,17 @@ type ring struct {
url string
}
// Pre-define all of our flags
var (
flagPort *int = flag.IntP("port", "p", 9285, "Port go-webring binds to")
flagList *string = flag.StringP("list", "l", "list.txt", "Path to list of webring members")
flagIndex *string = flag.StringP("index", "i", "index.html", "Path to home page template")
flagCert *string = flag.StringP("cert", "c", "cert.crt", "Path to certificate")
flagKey *string = flag.StringP("key", "k", "cert.key", "Path to private certificate key")
)
func main() {
flag.Parse()
list()
}