From 27bc16abedb0b9afc06705ec839c06d908cd91c9 Mon Sep 17 00:00:00 2001 From: Mohammed Al Sahaf Date: Thu, 13 Jul 2023 23:54:48 +0200 Subject: fileserver: add `export-template` sub-command to `file-server` (#5630) --- modules/caddyhttp/fileserver/command.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'modules') 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 + }, + }) }, }) } -- cgit v1.2.3