Repository: caddyserver/caddy
File: modules/caddyhttp/fileserver/command.go (Go)

Code before:
		Short: "Spins up a production-ready file server",
		Long: `
A simple but production-ready file server. Useful for quick deployments,
demos, and development.

The listener's socket address can be customized with the --listen flag.

If a domain name is specified with --domain, the default listener address
will be changed to the HTTPS port and the server will use HTTPS. If using
a public domain, ensure A/AAAA records are properly configured before
using this option.

By default, Zstandard and Gzip compression are enabled. Use --no-compress
to disable compression.

If --browse is enabled, requests for folders without an index file will
respond with a file listing.`,
		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", "l", "", "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", "a", false, "Enable the access log")
			cmd.Flags().BoolP("debug", "v", false, "Enable verbose debug logs")
      cmd.Flags().BoolP("no-compress", "", false, "Disable Zstandard and Gzip compression")
			cmd.Flags().StringSliceP("precompressed", "p", []string{}, "Specify precompression file extensions. Compression preference implied from flag order.")
			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, BrowseTemplate)
					return err
				},
			})
		},
	})
}

func cmdFileServer(fs caddycmd.Flags) (int, error) {
	caddy.TrapSignals()

	domain := fs.String("domain")
	root := fs.String("root")
	listen := fs.String("listen")
	browse := fs.Bool("browse")
	templates := fs.Bool("templates")
	accessLog := fs.Bool("access-log")
	debug := fs.Bool("debug")

Review comment (suggestion):
```suggestion
			cmd.Flags().BoolP("no-compress", "", false, "Disable Zstandard and Gzip compression")
```

Code after:
		Short: "Spins up a production-ready file server",
		Long: `
A simple but production-ready file server. Useful for quick deployments,
demos, and development.

The listener's socket address can be customized with the --listen flag.

If a domain name is specified with --domain, the default listener address
will be changed to the HTTPS port and the server will use HTTPS. If using
a public domain, ensure A/AAAA records are properly configured before
using this option.

By default, Zstandard and Gzip compression are enabled. Use --no-compress
to disable compression.

If --browse is enabled, requests for folders without an index file will
respond with a file listing.`,
		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", "l", "", "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", "a", false, "Enable the access log")
			cmd.Flags().BoolP("debug", "v", false, "Enable verbose debug logs")
			cmd.Flags().BoolP("no-compress", "", false, "Disable Zstandard and Gzip compression")
			cmd.Flags().StringSliceP("precompressed", "p", []string{}, "Specify precompression file extensions. Compression preference implied from flag order.")
			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, BrowseTemplate)
					return err
				},
			})
		},
	})
}

func cmdFileServer(fs caddycmd.Flags) (int, error) {
	caddy.TrapSignals()

	domain := fs.String("domain")
	root := fs.String("root")
	listen := fs.String("listen")
	browse := fs.Bool("browse")
	templates := fs.Bool("templates")
	accessLog := fs.Bool("access-log")
	debug := fs.Bool("debug")