update(ref bash complete)

This commit is contained in:
DeniskaRediska committed 2019-10-29 18:06:41 +03:00
1 parent 93071eef5b
commit 1a3458ebdd
14 files changed
+148 -200

No files matched your search

+2 -25
View File
@@ -2,12 +2,11 @@ package commonConfig
import (
"encoding/json"
"fmt"
"github.com/codegangsta/cli"
"github.com/integration-system/bellows"
"github.com/pkg/errors"
"github.com/tidwall/sjson"
"io/ioutil"
"isp-ctl/bash"
"isp-ctl/cfg"
"isp-ctl/command/utils"
"isp-ctl/flag"
@@ -20,7 +19,7 @@ func Set() cli.Command {
Name: "set",
Usage: "set common configurations",
Action: set.action,
BashComplete: set.bashComplete,
BashComplete: bash.CommonConfig.GetSetDelete,
}
}
@@ -95,25 +94,3 @@ func (g setCommand) action(ctx *cli.Context) {
}
}
}
func (g setCommand) bashComplete(ctx *cli.Context) {
if err := flag.CheckGlobal(ctx); err != nil {
return
}
commonConfigs, err := service.Config.GetMapCommonConfigByName()
if err != nil {
return
}
switch ctx.NArg() {
case 0:
for _, config := range commonConfigs {
fmt.Println(config.Name)
}
case 1:
if config, ok := commonConfigs[ctx.Args().First()]; ok {
for key, _ := range bellows.Flatten(config.Data) {
fmt.Printf(".%v\n", key)
}
}
}
}