Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Oct 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 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,23 +389,30 @@ 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 {
if (len(standard) > 0 && !skipStandard) || len(nonstandard) > 0 {
fmt.Println()
}
for _, mod := range unknown {
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
2 changes: 1 addition & 1 deletion cmd/packagesfuncs.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func getModules() (standard, nonstandard, unknown []moduleInfo, err error) {
}

func listModules(path string) error {
cmd := exec.Command(path, "list-modules", "--versions")
cmd := exec.Command(path, "list-modules", "--versions", "--skip-standard")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Run()
Expand Down