1
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-16 21:56:40 -05:00

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

This commit is contained in:
Mohammed Al Sahaf 2023-07-13 23:54:48 +02:00 committed by GitHub
parent bbe1952a59
commit 27bc16abed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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
},
})
},
})
}