update(ref bash complete)
This commit is contained in:
1 parent
93071eef5b
commit
1a3458ebdd
14 files changed
+148
-200
No files matched your search
@@ -2,11 +2,10 @@ package commonConfig
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/codegangsta/cli"
|
||||
"github.com/integration-system/bellows"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/tidwall/sjson"
|
||||
"isp-ctl/bash"
|
||||
"isp-ctl/command/utils"
|
||||
"isp-ctl/flag"
|
||||
"isp-ctl/service"
|
||||
@@ -17,7 +16,7 @@ func Delete() cli.Command {
|
||||
Name: "delete",
|
||||
Usage: "set common configurations",
|
||||
Action: deleteComm.action,
|
||||
BashComplete: deleteComm.bashComplete,
|
||||
BashComplete: bash.CommonConfig.GetSetDelete,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,25 +71,3 @@ func (g deleteCommand) action(ctx *cli.Context) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (g deleteCommand) 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/codegangsta/cli"
|
||||
"github.com/integration-system/bellows"
|
||||
"github.com/pkg/errors"
|
||||
"isp-ctl/bash"
|
||||
"isp-ctl/command/utils"
|
||||
"isp-ctl/flag"
|
||||
"isp-ctl/service"
|
||||
@@ -16,7 +16,7 @@ func Get() cli.Command {
|
||||
Name: "get",
|
||||
Usage: "get common configurations",
|
||||
Action: get.action,
|
||||
BashComplete: get.bashComplete,
|
||||
BashComplete: bash.CommonConfig.GetSetDelete,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,25 +67,3 @@ func (g getCommand) action(ctx *cli.Context) {
|
||||
utils.CheckObject(jsonObject, pathObject)
|
||||
}
|
||||
}
|
||||
|
||||
func (g getCommand) 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/codegangsta/cli"
|
||||
"github.com/pkg/errors"
|
||||
"isp-ctl/bash"
|
||||
"isp-ctl/command/utils"
|
||||
"isp-ctl/flag"
|
||||
"isp-ctl/service"
|
||||
@@ -14,7 +15,7 @@ func Link() cli.Command {
|
||||
Name: "link",
|
||||
Usage: "link common configurations to module configuration",
|
||||
Action: link.action,
|
||||
BashComplete: link.bashComplete,
|
||||
BashComplete: bash.CommonConfig.LinkUnlink,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,27 +90,3 @@ func (g linkCommand) action(ctx *cli.Context) {
|
||||
fmt.Printf("\n")
|
||||
}
|
||||
}
|
||||
|
||||
func (g linkCommand) 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 arrayOfModules, err := service.Config.GetAvailableConfigs(); err != nil {
|
||||
return
|
||||
} else {
|
||||
for _, module := range arrayOfModules {
|
||||
fmt.Println(module.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/codegangsta/cli"
|
||||
"github.com/pkg/errors"
|
||||
"isp-ctl/bash"
|
||||
"isp-ctl/command/utils"
|
||||
"isp-ctl/flag"
|
||||
"isp-ctl/service"
|
||||
@@ -14,7 +15,7 @@ func Remove() cli.Command {
|
||||
Name: "remove",
|
||||
Usage: "remove common configurations",
|
||||
Action: remove.action,
|
||||
BashComplete: remove.bashComplete,
|
||||
BashComplete: bash.CommonConfig.Remove,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,19 +54,3 @@ func (g removeCommand) action(ctx *cli.Context) {
|
||||
fmt.Printf("count deleted config: %d\n", deleted)
|
||||
}
|
||||
}
|
||||
|
||||
func (g removeCommand) 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/codegangsta/cli"
|
||||
"github.com/pkg/errors"
|
||||
"isp-ctl/bash"
|
||||
"isp-ctl/command/utils"
|
||||
"isp-ctl/flag"
|
||||
"isp-ctl/service"
|
||||
@@ -14,7 +15,7 @@ func UnLink() cli.Command {
|
||||
Name: "unlink",
|
||||
Usage: "unlink common configurations from module configuration",
|
||||
Action: unlink.action,
|
||||
BashComplete: unlink.bashComplete,
|
||||
BashComplete: bash.CommonConfig.LinkUnlink,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,27 +92,3 @@ func (g unlinkCommand) action(ctx *cli.Context) {
|
||||
fmt.Printf("\n")
|
||||
}
|
||||
}
|
||||
|
||||
func (g unlinkCommand) 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 arrayOfModules, err := service.Config.GetAvailableConfigs(); err != nil {
|
||||
return
|
||||
} else {
|
||||
for _, module := range arrayOfModules {
|
||||
fmt.Println(module.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user