add 'contain' command for common configs
add flag 'full' for 'get' command update bash complete
This commit is contained in:
1 parent
1a3458ebdd
commit
8b8815d2f2
21 files changed
+348
-54
No files matched your search
+20
-3
@@ -1,6 +1,7 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/codegangsta/cli"
|
||||
"isp-ctl/bash"
|
||||
"isp-ctl/command/utils"
|
||||
@@ -13,7 +14,10 @@ func Get() cli.Command {
|
||||
Name: "get",
|
||||
Usage: "get configuration by module_name",
|
||||
Action: get.action,
|
||||
BashComplete: bash.Module.GetSetDelete,
|
||||
BashComplete: bash.Module.ModuleName_ModuleData,
|
||||
Flags: []cli.Flag{
|
||||
flag.WithCommonConfig,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,12 +33,20 @@ func (g getCommand) action(ctx *cli.Context) {
|
||||
moduleName := ctx.Args().First()
|
||||
pathObject := ctx.Args().Get(1)
|
||||
|
||||
moduleConfiguration, jsonObject, err := service.Config.GetConfigurationAndJsonByModuleName(moduleName)
|
||||
config, err := service.Config.GetConfigurationByModuleName(moduleName)
|
||||
if err != nil {
|
||||
utils.PrintError(err)
|
||||
return
|
||||
}
|
||||
|
||||
data := config.Data
|
||||
if ctx.Bool(flag.WithCommonConfig.Name) {
|
||||
if data, err = service.Config.CompileDataWithCommonConfigs(data, config.CommonConfigs); err != nil {
|
||||
utils.PrintError(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
pathObject, err = utils.CheckPath(pathObject)
|
||||
if err != nil {
|
||||
utils.PrintError(err)
|
||||
@@ -42,8 +54,13 @@ func (g getCommand) action(ctx *cli.Context) {
|
||||
}
|
||||
|
||||
if pathObject == "" {
|
||||
utils.PrintAnswer(moduleConfiguration.Data)
|
||||
utils.PrintAnswer(data)
|
||||
} else {
|
||||
jsonObject, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
utils.PrintError(err)
|
||||
return
|
||||
}
|
||||
utils.CheckObject(jsonObject, pathObject)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user