ref
This commit is contained in:
1 parent
8b8815d2f2
commit
cf23b95af1
20 files changed
+361
-423
No files matched your search
@@ -0,0 +1,55 @@
|
||||
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 Contain() cli.Command {
|
||||
return cli.Command{
|
||||
Name: "contain",
|
||||
Usage: "availability common configuration in module",
|
||||
Action: contain.action,
|
||||
BashComplete: bash.Get(bash.CommonConfigName, bash.Empty).Complete,
|
||||
}
|
||||
}
|
||||
|
||||
var contain containCommand
|
||||
|
||||
type containCommand struct{}
|
||||
|
||||
func (g containCommand) 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, err := service.Config.GetLinksCommonConfig(config.Id)
|
||||
if err != nil {
|
||||
utils.PrintError(err)
|
||||
} else {
|
||||
fmt.Printf("config [%s] linked with next modules:\n", configName)
|
||||
for _, link := range links {
|
||||
fmt.Printf("[%s] ", link)
|
||||
}
|
||||
fmt.Printf("\n")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user