contented: move flag parsing, consts into block declaration

This commit is contained in:
mappu 2023-05-19 19:04:50 +12:00
parent 5ce06d6e6b
commit 77a4061cdd
2 changed files with 18 additions and 13 deletions

View File

@ -20,9 +20,12 @@ var staticAssets embed.FS
var SERVER_HEADER string = `contented/0.0.0-dev`
const DEFAULT_MAX_CONCURRENT_THUMBS = 16
const (
DEFAULT_MAX_CONCURRENT_THUMBS = 16
const ALBUM_MIMETYPE = `contented/album`
ALBUM_MIMETYPE = `contented/album`
)
type ServerPublicProperties struct {
AppTitle string

View File

@ -12,17 +12,19 @@ import (
func main() {
cwd, _ := os.Getwd()
listenAddr := flag.String("listen", "127.0.0.1:80", "IP/Port to bind server")
dataDir := flag.String("data", cwd, "Directory for stored content")
dbPath := flag.String("db", "contented.db", "Path for metadata database")
appTitle := flag.String("title", "contented", "Title used in web interface")
maxUploadMb := flag.Int("max", 8, "Maximum size of uploaded files in MiB (set zero for unlimited)")
maxUploadSpeed := flag.Int("speed", 0, "Maximum upload speed in bytes/sec (set zero for unlimited)")
trustXForwardedFor := flag.Bool("trustXForwardedFor", false, "Trust X-Forwarded-For reverse proxy headers")
enableHomepage := flag.Bool("enableHomepage", true, "Enable homepage (disable for embedded use only)")
enableUpload := flag.Bool("enableUpload", true, "Enable uploads (disable for read-only mode)")
diskFilesWorldReadable := flag.Bool("diskFilesWorldReadable", false, "Save files as 0644 instead of 0600")
maxConcurrentThumbs := flag.Int("concurrentthumbs", contented.DEFAULT_MAX_CONCURRENT_THUMBS, "Simultaneous thumbnail generation")
var (
listenAddr = flag.String("listen", "127.0.0.1:80", "IP/Port to bind server")
dataDir = flag.String("data", cwd, "Directory for stored content")
dbPath = flag.String("db", "contented.db", "Path for metadata database")
appTitle = flag.String("title", "contented", "Title used in web interface")
maxUploadMb = flag.Int("max", 8, "Maximum size of uploaded files in MiB (set zero for unlimited)")
maxUploadSpeed = flag.Int("speed", 0, "Maximum upload speed in bytes/sec (set zero for unlimited)")
trustXForwardedFor = flag.Bool("trustXForwardedFor", false, "Trust X-Forwarded-For reverse proxy headers")
enableHomepage = flag.Bool("enableHomepage", true, "Enable homepage (disable for embedded use only)")
enableUpload = flag.Bool("enableUpload", true, "Enable uploads (disable for read-only mode)")
diskFilesWorldReadable = flag.Bool("diskFilesWorldReadable", false, "Save files as 0644 instead of 0600")
maxConcurrentThumbs = flag.Int("concurrentthumbs", contented.DEFAULT_MAX_CONCURRENT_THUMBS, "Simultaneous thumbnail generation")
)
flag.Parse()