add 'contain' command for common configs

add flag 'full' for 'get' command
update bash complete
This commit is contained in:
DeniskaRediska committed 2019-10-30 14:58:50 +03:00
1 parent 1a3458ebdd
commit 8b8815d2f2
21 files changed
+348 -54

No files matched your search

+9 -2
View File
@@ -1,6 +1,7 @@
package command
import (
"encoding/json"
"github.com/codegangsta/cli"
"github.com/tidwall/sjson"
"isp-ctl/bash"
@@ -14,7 +15,7 @@ func Delete() cli.Command {
Name: "delete",
Usage: "delete configuration by module_name",
Action: deleteComm.action,
BashComplete: bash.Module.GetSetDelete,
BashComplete: bash.Module.ModuleName_ModuleData,
}
}
@@ -30,7 +31,7 @@ func (d deleteCommand) action(ctx *cli.Context) {
moduleName := ctx.Args().First()
pathObject := ctx.Args().Get(1)
moduleConfiguration, jsonObject, err := service.Config.GetConfigurationAndJsonByModuleName(moduleName)
moduleConfiguration, err := service.Config.GetConfigurationByModuleName(moduleName)
if err != nil {
utils.PrintError(err)
return
@@ -45,6 +46,12 @@ func (d deleteCommand) action(ctx *cli.Context) {
if pathObject == "" {
utils.CreateUpdateConfig("", moduleConfiguration)
} else {
jsonObject, err := json.Marshal(moduleConfiguration.Data)
if err != nil {
utils.PrintError(err)
return
}
if stringToChange, err := sjson.Delete(string(jsonObject), pathObject); err != nil {
utils.PrintError(err)
return