@marcel91200 / caddy Mirror · read-only / commits / 062657d0
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 14, 01:30 UTC

caddycmd: Add `--skip-standard` to `list-modules` command, quieter output (#4386)

* caddycmd: Add --skip-standard to list-modules command, quieter output * caddycmd: Also quiet `caddy upgrade` output, redundant information

Francis Lavoie committed Oct 18, 2021 at 14:19 UTC 062657d0d80aa1c2e3af51414db634f49c9a03a0
3 files changed +16 -7
cmd/commandfuncs.go
+14 -6
@@ -360,6 +360,7 @@ func cmdBuildInfo(fl Flags) (int, error) {
360 func cmdListModules(fl Flags) (int, error) {
361 packages := fl.Bool("packages")
362 versions := fl.Bool("versions")
363 + skipStandard := fl.Bool("skip-standard")
364
365 printModuleInfo := func(mi moduleInfo) {
366 fmt.Print(mi.caddyModuleID)
@@ -388,14 +389,19 @@ func cmdListModules(fl Flags) (int, error) {
389 return caddy.ExitCodeSuccess, nil
390 }
391
391 - if len(standard) > 0 {
392 - for _, mod := range standard {
393 - printModuleInfo(mod)
392 + // Standard modules (always shipped with Caddy)
393 + if !skipStandard {
394 + if len(standard) > 0 {
395 + for _, mod := range standard {
396 + printModuleInfo(mod)
397 + }
398 }
399 + fmt.Printf("\n Standard modules: %d\n", len(standard))
400 }
396 - fmt.Printf("\n Standard modules: %d\n", len(standard))
401 +
402 + // Non-standard modules (third party plugins)
403 if len(nonstandard) > 0 {
398 - if len(standard) > 0 {
404 + if len(standard) > 0 && !skipStandard {
405 fmt.Println()
406 }
407 for _, mod := range nonstandard {
@@ -403,8 +409,10 @@ func cmdListModules(fl Flags) (int, error) {
409 }
410 }
411 fmt.Printf("\n Non-standard modules: %d\n", len(nonstandard))
412 +
413 + // Unknown modules (couldn't get Caddy module info)
414 if len(unknown) > 0 {
407 - if len(standard) > 0 || len(nonstandard) > 0 {
415 + if (len(standard) > 0 && !skipStandard) || len(nonstandard) > 0 {
416 fmt.Println()
417 }
418 for _, mod := range unknown {
cmd/commands.go
+1
@@ -208,6 +208,7 @@ config file; otherwise the default is assumed.`,
208 fs := flag.NewFlagSet("list-modules", flag.ExitOnError)
209 fs.Bool("packages", false, "Print package paths")
210 fs.Bool("versions", false, "Print version information")
211 + fs.Bool("skip-standard", false, "Skip printing standard modules")
212 return fs
213 }(),
214 })
cmd/packagesfuncs.go
+1 -1
@@ -220,7 +220,7 @@ func getModules() (standard, nonstandard, unknown []moduleInfo, err error) {
220 }
221
222 func listModules(path string) error {
223 - cmd := exec.Command(path, "list-modules", "--versions")
223 + cmd := exec.Command(path, "list-modules", "--versions", "--skip-standard")
224 cmd.Stdout = os.Stdout
225 cmd.Stderr = os.Stderr
226 err := cmd.Run()