@marcel91200 / caddy Mirror · read-only / commits / 27bc16ab
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 13, 00:30 UTC

fileserver: add `export-template` sub-command to `file-server` (#5630)

Mohammed Al Sahaf committed Jul 13, 2023 at 23:54 UTC 27bc16abedb0b9afc06705ec839c06d908cd91c9
1 file changed +11
modules/caddyhttp/fileserver/command.go
+11
@@ -16,7 +16,9 @@ package fileserver
16
17 import (
18 "encoding/json"
19 + "io"
20 "log"
21 + "os"
22 "strconv"
23 "time"
24
@@ -57,6 +59,15 @@ respond with a file listing.`,
59 cmd.Flags().BoolP("access-log", "", false, "Enable the access log")
60 cmd.Flags().BoolP("debug", "v", false, "Enable verbose debug logs")
61 cmd.RunE = caddycmd.WrapCommandFuncForCobra(cmdFileServer)
62 + cmd.AddCommand(&cobra.Command{
63 + Use: "export-template",
64 + Short: "Exports the default file browser template",
65 + Example: "caddy file-server export-template > browse.html",
66 + RunE: func(cmd *cobra.Command, args []string) error {
67 + _, err := io.WriteString(os.Stdout, defaultBrowseTemplate)
68 + return err
69 + },
70 + })
71 },
72 })
73 }