summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/fileserver
diff options
context:
space:
mode:
Diffstat (limited to 'modules/caddyhttp/fileserver')
-rw-r--r--modules/caddyhttp/fileserver/command.go24
1 files changed, 11 insertions, 13 deletions
diff --git a/modules/caddyhttp/fileserver/command.go b/modules/caddyhttp/fileserver/command.go
index bc7f981..697ec34 100644
--- a/modules/caddyhttp/fileserver/command.go
+++ b/modules/caddyhttp/fileserver/command.go
@@ -16,7 +16,6 @@ package fileserver
import (
"encoding/json"
- "flag"
"log"
"strconv"
"time"
@@ -27,13 +26,13 @@ import (
"github.com/caddyserver/caddy/v2/modules/caddyhttp"
caddytpl "github.com/caddyserver/caddy/v2/modules/caddyhttp/templates"
"github.com/caddyserver/certmagic"
+ "github.com/spf13/cobra"
"go.uber.org/zap"
)
func init() {
caddycmd.RegisterCommand(caddycmd.Command{
Name: "file-server",
- Func: cmdFileServer,
Usage: "[--domain <example.com>] [--root <path>] [--listen <addr>] [--browse] [--access-log]",
Short: "Spins up a production-ready file server",
Long: `
@@ -49,17 +48,16 @@ using this option.
If --browse is enabled, requests for folders without an index file will
respond with a file listing.`,
- Flags: func() *flag.FlagSet {
- fs := flag.NewFlagSet("file-server", flag.ExitOnError)
- fs.String("domain", "", "Domain name at which to serve the files")
- fs.String("root", "", "The path to the root of the site")
- fs.String("listen", "", "The address to which to bind the listener")
- fs.Bool("browse", false, "Enable directory browsing")
- fs.Bool("templates", false, "Enable template rendering")
- fs.Bool("access-log", false, "Enable the access log")
- fs.Bool("debug", false, "Enable verbose debug logs")
- return fs
- }(),
+ CobraFunc: func(cmd *cobra.Command) {
+ cmd.Flags().StringP("domain", "d", "", "Domain name at which to serve the files")
+ cmd.Flags().StringP("root", "r", "", "The path to the root of the site")
+ cmd.Flags().StringP("listen", "", "", "The address to which to bind the listener")
+ cmd.Flags().BoolP("browse", "b", false, "Enable directory browsing")
+ cmd.Flags().BoolP("templates", "t", false, "Enable template rendering")
+ 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)
+ },
})
}