summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammed Al Sahaf <msaa1990@gmail.com>2023-07-13 23:54:48 +0200
committerGitHub <noreply@github.com>2023-07-13 15:54:48 -0600
commit27bc16abedb0b9afc06705ec839c06d908cd91c9 (patch)
tree333d68cb082be83c3d09fbf1d524f657369a4296
parentbbe1952a59a196b7598c6488beb770ec38a70dfc (diff)
fileserver: add `export-template` sub-command to `file-server` (#5630)
-rw-r--r--modules/caddyhttp/fileserver/command.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/modules/caddyhttp/fileserver/command.go b/modules/caddyhttp/fileserver/command.go
index 0112a5f..bccaf2f 100644
--- a/modules/caddyhttp/fileserver/command.go
+++ b/modules/caddyhttp/fileserver/command.go
@@ -16,7 +16,9 @@ package fileserver
import (
"encoding/json"
+ "io"
"log"
+ "os"
"strconv"
"time"
@@ -57,6 +59,15 @@ respond with a file listing.`,
cmd.Flags().BoolP("access-log", "", false, "Enable the access log")
cmd.Flags().BoolP("debug", "v", false, "Enable verbose debug logs")
cmd.RunE = caddycmd.WrapCommandFuncForCobra(cmdFileServer)
+ cmd.AddCommand(&cobra.Command{
+ Use: "export-template",
+ Short: "Exports the default file browser template",
+ Example: "caddy file-server export-template > browse.html",
+ RunE: func(cmd *cobra.Command, args []string) error {
+ _, err := io.WriteString(os.Stdout, defaultBrowseTemplate)
+ return err
+ },
+ })
},
})
}