ref
This commit is contained in:
1 parent
8b8815d2f2
commit
cf23b95af1
20 files changed
+361
-423
No files matched your search
@@ -0,0 +1,56 @@
|
||||
package common_config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/codegangsta/cli"
|
||||
"github.com/pkg/errors"
|
||||
"isp-ctl/bash"
|
||||
"isp-ctl/command/utils"
|
||||
"isp-ctl/flag"
|
||||
"isp-ctl/service"
|
||||
)
|
||||
|
||||
func Remove() cli.Command {
|
||||
return cli.Command{
|
||||
Name: "remove",
|
||||
Usage: "remove common configurations",
|
||||
Action: remove.action,
|
||||
BashComplete: bash.Get(bash.CommonConfigName, bash.Empty).Complete,
|
||||
}
|
||||
}
|
||||
|
||||
var remove removeCommand
|
||||
|
||||
type removeCommand struct{}
|
||||
|
||||
func (g removeCommand) action(ctx *cli.Context) {
|
||||
if err := flag.CheckGlobal(ctx); err != nil {
|
||||
utils.PrintError(err)
|
||||
return
|
||||
}
|
||||
|
||||
configName := ctx.Args().First()
|
||||
|
||||
if configName == "" {
|
||||
utils.PrintError(errors.New("empty common config name"))
|
||||
return
|
||||
}
|
||||
|
||||
config, err := service.Config.GetCommonConfigByName(configName)
|
||||
if err != nil {
|
||||
utils.PrintError(err)
|
||||
return
|
||||
}
|
||||
|
||||
links, deleted, err := service.Config.DeleteCommonConfig(config.Id)
|
||||
if err != nil {
|
||||
utils.PrintError(err)
|
||||
return
|
||||
}
|
||||
|
||||
if deleted {
|
||||
fmt.Printf("config [%s] deleted\n", config.Name)
|
||||
} else {
|
||||
fmt.Printf("config [%s] not deleted, need unlink in next modules:\n%v\n", config.Name, links)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user