mirror of
https://github.com/caddyserver/caddy.git
synced 2024-11-25 09:05:44 +08:00
refactored add/remove packages to print warnings on present/absent packages
This commit is contained in:
parent
6ab9fb6f74
commit
06e146ccbe
|
@ -61,7 +61,8 @@ func cmdAddPackage(fl Flags) (int, error) {
|
|||
|
||||
for _, arg := range fl.Args() {
|
||||
if _, ok := pluginPkgs[arg]; ok {
|
||||
return caddy.ExitCodeFailedStartup, fmt.Errorf("package is already added")
|
||||
fmt.Printf("[WARNING] package %s is already added", arg)
|
||||
continue
|
||||
}
|
||||
pluginPkgs[arg] = struct{}{}
|
||||
}
|
||||
|
@ -85,7 +86,8 @@ func cmdRemovePackage(fl Flags) (int, error) {
|
|||
for _, arg := range fl.Args() {
|
||||
if _, ok := pluginPkgs[arg]; !ok {
|
||||
// package does not exist
|
||||
return caddy.ExitCodeFailedStartup, fmt.Errorf("package is not added")
|
||||
fmt.Printf("[WARNING] package %s is not added", arg)
|
||||
continue
|
||||
}
|
||||
delete(pluginPkgs, arg)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user