Skip to content

Commit

Permalink
caddycmd: Add --skip-standard to list-modules command, quieter output
Browse files Browse the repository at this point in the history
  • Loading branch information
francislavoie committed Oct 16, 2021
1 parent 95c0350 commit ca1aae6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
18 changes: 13 additions & 5 deletions cmd/commandfuncs.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ func cmdBuildInfo(fl Flags) (int, error) {
func cmdListModules(fl Flags) (int, error) {
packages := fl.Bool("packages")
versions := fl.Bool("versions")
skipStandard := fl.Bool("skip-standard")

printModuleInfo := func(mi moduleInfo) {
fmt.Print(mi.caddyModuleID)
Expand Down Expand Up @@ -388,21 +389,28 @@ func cmdListModules(fl Flags) (int, error) {
return caddy.ExitCodeSuccess, nil
}

if len(standard) > 0 {
for _, mod := range standard {
printModuleInfo(mod)
// Standard modules (always shipped with Caddy)
if !skipStandard {
if len(standard) > 0 {
for _, mod := range standard {
printModuleInfo(mod)
}
}
fmt.Printf("\n Standard modules: %d\n", len(standard))
}
fmt.Printf("\n Standard modules: %d\n", len(standard))

// Non-standard modules (third party plugins)
if len(nonstandard) > 0 {
if len(standard) > 0 {
if len(standard) > 0 && !skipStandard {
fmt.Println()
}
for _, mod := range nonstandard {
printModuleInfo(mod)
}
}
fmt.Printf("\n Non-standard modules: %d\n", len(nonstandard))

// Unknown modules (couldn't get Caddy module info)
if len(unknown) > 0 {
if len(standard) > 0 || len(nonstandard) > 0 {
fmt.Println()
Expand Down
1 change: 1 addition & 0 deletions cmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ config file; otherwise the default is assumed.`,
fs := flag.NewFlagSet("list-modules", flag.ExitOnError)
fs.Bool("packages", false, "Print package paths")
fs.Bool("versions", false, "Print version information")
fs.Bool("skip-standard", false, "Skip printing standard modules")
return fs
}(),
})
Expand Down

0 comments on commit ca1aae6

Please sign in to comment.