feat: support service completion

Closes coop-cloud/organising#165.
This commit is contained in:
2021-09-16 09:10:05 +02:00
parent 6c9bb89a10
commit 6794236b77
2 changed files with 50 additions and 9 deletions

View File

@ -102,15 +102,24 @@ var appRunCommand = &cli.Command{
return nil
},
BashComplete: func(c *cli.Context) {
appNames, err := config.GetAppNames()
if err != nil {
logrus.Warn(err)
}
if c.NArg() > 0 {
return
}
for _, a := range appNames {
fmt.Println(a)
switch c.NArg() {
case 0:
appNames, err := config.GetAppNames()
if err != nil {
logrus.Warn(err)
}
for _, a := range appNames {
fmt.Println(a)
}
case 1:
appName := c.Args().First()
serviceNames, err := config.GetAppServiceNames(appName)
if err != nil {
logrus.Warn(err)
}
for _, s := range serviceNames {
fmt.Println(s)
}
}
},
}