mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-14 06:46:27 +03:00
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
This commit is contained in:
parent
b092061591
commit
062657d0d8
3 changed files with 18 additions and 9 deletions
|
@ -360,6 +360,7 @@ func cmdBuildInfo(fl Flags) (int, error) {
|
||||||
func cmdListModules(fl Flags) (int, error) {
|
func cmdListModules(fl Flags) (int, error) {
|
||||||
packages := fl.Bool("packages")
|
packages := fl.Bool("packages")
|
||||||
versions := fl.Bool("versions")
|
versions := fl.Bool("versions")
|
||||||
|
skipStandard := fl.Bool("skip-standard")
|
||||||
|
|
||||||
printModuleInfo := func(mi moduleInfo) {
|
printModuleInfo := func(mi moduleInfo) {
|
||||||
fmt.Print(mi.caddyModuleID)
|
fmt.Print(mi.caddyModuleID)
|
||||||
|
@ -388,14 +389,19 @@ func cmdListModules(fl Flags) (int, error) {
|
||||||
return caddy.ExitCodeSuccess, nil
|
return caddy.ExitCodeSuccess, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(standard) > 0 {
|
// Standard modules (always shipped with Caddy)
|
||||||
for _, mod := range standard {
|
if !skipStandard {
|
||||||
printModuleInfo(mod)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fmt.Printf("\n Standard modules: %d\n", len(standard))
|
|
||||||
if len(nonstandard) > 0 {
|
|
||||||
if len(standard) > 0 {
|
if len(standard) > 0 {
|
||||||
|
for _, mod := range standard {
|
||||||
|
printModuleInfo(mod)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fmt.Printf("\n Standard modules: %d\n", len(standard))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Non-standard modules (third party plugins)
|
||||||
|
if len(nonstandard) > 0 {
|
||||||
|
if len(standard) > 0 && !skipStandard {
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
}
|
}
|
||||||
for _, mod := range nonstandard {
|
for _, mod := range nonstandard {
|
||||||
|
@ -403,8 +409,10 @@ func cmdListModules(fl Flags) (int, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Printf("\n Non-standard modules: %d\n", len(nonstandard))
|
fmt.Printf("\n Non-standard modules: %d\n", len(nonstandard))
|
||||||
|
|
||||||
|
// Unknown modules (couldn't get Caddy module info)
|
||||||
if len(unknown) > 0 {
|
if len(unknown) > 0 {
|
||||||
if len(standard) > 0 || len(nonstandard) > 0 {
|
if (len(standard) > 0 && !skipStandard) || len(nonstandard) > 0 {
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
}
|
}
|
||||||
for _, mod := range unknown {
|
for _, mod := range unknown {
|
||||||
|
|
|
@ -208,6 +208,7 @@ config file; otherwise the default is assumed.`,
|
||||||
fs := flag.NewFlagSet("list-modules", flag.ExitOnError)
|
fs := flag.NewFlagSet("list-modules", flag.ExitOnError)
|
||||||
fs.Bool("packages", false, "Print package paths")
|
fs.Bool("packages", false, "Print package paths")
|
||||||
fs.Bool("versions", false, "Print version information")
|
fs.Bool("versions", false, "Print version information")
|
||||||
|
fs.Bool("skip-standard", false, "Skip printing standard modules")
|
||||||
return fs
|
return fs
|
||||||
}(),
|
}(),
|
||||||
})
|
})
|
||||||
|
|
|
@ -220,7 +220,7 @@ func getModules() (standard, nonstandard, unknown []moduleInfo, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func listModules(path string) 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.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
err := cmd.Run()
|
err := cmd.Run()
|
||||||
|
|
Loading…
Reference in a new issue