This commit is contained in:
DeniskaRediska committed 2019-07-17 11:14:17 +03:00
1 parent 79e240037f
commit 9078060e65
20 files changed
+1152

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
package command
import (
"fmt"
"github.com/codegangsta/cli"
"github.com/tidwall/sjson"
)
func Delete() cli.Command {
return cli.Command{
Name: "delete",
Usage: "delete configuration info by module_name",
Action: deleteComm.action,
}
}
var deleteComm deleteCommand
type deleteCommand struct{}
func (d deleteCommand) action(c *cli.Context) {
if err := checkFlags(c); err != nil {
fmt.Println(err)
return
}
moduleName := c.Args().First()
pathObject := c.Args().Get(1)
moduleConfiguration, jsonObject := getModuleConfiguration(moduleName)
if moduleConfiguration == nil {
return
}
if pathObject == "" {
createUpdateConfig("", moduleConfiguration)
} else {
if stringToChange, err := sjson.Delete(string(jsonObject), pathObject); err != nil {
fmt.Println(err)
return
} else {
createUpdateConfig(stringToChange, moduleConfiguration)
}
}
}