2024-05-16 17:14:51: merge [master:7e9513f98b794c4f45ee5b69d84f292334c57d68];
This commit is contained in:
1 parent
79e240037f
commit
13803ab804
39 files changed
+2879
No files matched your search
@@ -0,0 +1,84 @@
|
||||
package bash
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/integration-system/bellows"
|
||||
"github.com/urfave/cli/v2"
|
||||
"ispctl/flag"
|
||||
"ispctl/service"
|
||||
)
|
||||
|
||||
const (
|
||||
CommonConfigName bashArg = "config_name"
|
||||
CommonConfigData bashArg = "config_data"
|
||||
ModuleName bashArg = "module_name"
|
||||
ModuleData bashArg = "module_data"
|
||||
Empty bashArg = "empty"
|
||||
)
|
||||
|
||||
type bashArg string
|
||||
|
||||
type bashCommand struct {
|
||||
first bashArg
|
||||
second bashArg
|
||||
}
|
||||
|
||||
func Get(first bashArg, second bashArg) *bashCommand {
|
||||
return &bashCommand{
|
||||
first: first,
|
||||
second: second,
|
||||
}
|
||||
}
|
||||
|
||||
func (c bashCommand) Complete(ctx *cli.Context) {
|
||||
if err := flag.CheckGlobal(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
commonConfigs, err := service.Config.GetMapNameCommonConfig()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
switch ctx.NArg() {
|
||||
case 0:
|
||||
switch c.first {
|
||||
case ModuleName:
|
||||
if arrayOfModules, err := service.Config.GetAvailableConfigs(); err != nil {
|
||||
return
|
||||
} else {
|
||||
for _, module := range arrayOfModules {
|
||||
fmt.Println(module.Name)
|
||||
}
|
||||
}
|
||||
case CommonConfigName:
|
||||
for _, config := range commonConfigs {
|
||||
fmt.Println(config.Name)
|
||||
}
|
||||
}
|
||||
case 1:
|
||||
switch c.second {
|
||||
case CommonConfigData:
|
||||
if config, ok := commonConfigs[ctx.Args().First()]; ok {
|
||||
for key, _ := range bellows.Flatten(config.Data) {
|
||||
fmt.Printf(".%v\n", key)
|
||||
}
|
||||
}
|
||||
case ModuleName:
|
||||
if arrayOfModules, err := service.Config.GetAvailableConfigs(); err != nil {
|
||||
return
|
||||
} else {
|
||||
for _, module := range arrayOfModules {
|
||||
fmt.Println(module.Name)
|
||||
}
|
||||
}
|
||||
case ModuleData:
|
||||
if moduleConfiguration, err := service.Config.GetConfigurationByModuleName(ctx.Args().First()); err != nil {
|
||||
return
|
||||
} else {
|
||||
for key, _ := range bellows.Flatten(moduleConfiguration.Data) {
|
||||
fmt.Printf(".%v\n", key)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user