feat: auto-complete app and recipe names
continuous-integration/drone/pr Build is passing
Details
continuous-integration/drone/pr Build is passing
Details
This commit is contained in:
parent
5f50c7960c
commit
4c216fdf40
|
@ -95,6 +95,7 @@ can take some time.
|
|||
}
|
||||
|
||||
table.Render()
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
|
||||
"coopcloud.tech/abra/cli/internal"
|
||||
"coopcloud.tech/abra/pkg/client"
|
||||
"coopcloud.tech/abra/pkg/config"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
dockerClient "github.com/docker/docker/client"
|
||||
|
@ -109,4 +110,16 @@ var appLogsCommand = &cli.Command{
|
|||
|
||||
return nil
|
||||
},
|
||||
BashComplete: func(c *cli.Context) {
|
||||
appNames, err := config.GetAppsNames()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if c.NArg() > 0 {
|
||||
return
|
||||
}
|
||||
for _, a := range appNames {
|
||||
fmt.Println(a)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -78,6 +78,18 @@ var appNewCommand = &cli.Command{
|
|||
},
|
||||
ArgsUsage: "<recipe>",
|
||||
Action: action,
|
||||
BashComplete: func(c *cli.Context) {
|
||||
catl, err := catalogue.ReadRecipeCatalogue()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if c.NArg() > 0 {
|
||||
return
|
||||
}
|
||||
for name, _ := range catl {
|
||||
fmt.Println(name)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
// getRecipeMeta retrieves the recipe metadata from the recipe catalogue.
|
||||
|
|
|
@ -2,11 +2,13 @@ package app
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
abraFormatter "coopcloud.tech/abra/cli/formatter"
|
||||
"coopcloud.tech/abra/cli/internal"
|
||||
"coopcloud.tech/abra/pkg/client"
|
||||
"coopcloud.tech/abra/pkg/config"
|
||||
"github.com/docker/cli/cli/command/formatter"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
|
@ -54,4 +56,16 @@ var appPsCommand = &cli.Command{
|
|||
table.Render()
|
||||
return nil
|
||||
},
|
||||
BashComplete: func(c *cli.Context) {
|
||||
appNames, err := config.GetAppsNames()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if c.NArg() > 0 {
|
||||
return
|
||||
}
|
||||
for _, a := range appNames {
|
||||
fmt.Println(a)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -155,4 +155,16 @@ var appRemoveCommand = &cli.Command{
|
|||
|
||||
return nil
|
||||
},
|
||||
BashComplete: func(c *cli.Context) {
|
||||
appNames, err := config.GetAppsNames()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if c.NArg() > 0 {
|
||||
return
|
||||
}
|
||||
for _, a := range appNames {
|
||||
fmt.Println(a)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -2,10 +2,12 @@ package app
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"coopcloud.tech/abra/cli/internal"
|
||||
"coopcloud.tech/abra/pkg/client"
|
||||
stack "coopcloud.tech/abra/pkg/client/stack"
|
||||
"coopcloud.tech/abra/pkg/config"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
@ -35,4 +37,16 @@ volumes as eligiblef or pruning once undeployed.
|
|||
|
||||
return nil
|
||||
},
|
||||
BashComplete: func(c *cli.Context) {
|
||||
appNames, err := config.GetDeployedApps()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if c.NArg() > 0 {
|
||||
return
|
||||
}
|
||||
for _, a := range appNames {
|
||||
fmt.Println(a)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -2,10 +2,12 @@ package app
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
abraFormatter "coopcloud.tech/abra/cli/formatter"
|
||||
"coopcloud.tech/abra/cli/internal"
|
||||
"coopcloud.tech/abra/pkg/client"
|
||||
"coopcloud.tech/abra/pkg/config"
|
||||
"github.com/AlecAivazis/survey/v2"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli/v2"
|
||||
|
@ -81,6 +83,18 @@ var appVolumeRemoveCommand = &cli.Command{
|
|||
|
||||
return nil
|
||||
},
|
||||
BashComplete: func(c *cli.Context) {
|
||||
appNames, err := config.GetAppsNames()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if c.NArg() > 0 {
|
||||
return
|
||||
}
|
||||
for _, a := range appNames {
|
||||
fmt.Println(a)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
var appVolumeCommand = &cli.Command{
|
||||
|
|
|
@ -177,6 +177,46 @@ func GetApps(appFiles AppFiles) ([]App, error) {
|
|||
return apps, nil
|
||||
}
|
||||
|
||||
func GetAppsNames() ([]string, error) {
|
||||
appFiles, err := LoadAppFiles("")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
apps, err := GetApps(appFiles)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var appNames []string
|
||||
for _, app := range apps {
|
||||
appNames = append(appNames, app.Name)
|
||||
}
|
||||
|
||||
return appNames, nil
|
||||
}
|
||||
|
||||
func GetDeployedApps() ([]string, error) {
|
||||
appFiles, err := LoadAppFiles("")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
apps, err := GetApps(appFiles)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
statuses, err := GetAppStatuses(appFiles)
|
||||
|
||||
var appNames []string
|
||||
for _, app := range apps {
|
||||
status := statuses[app.StackName()]
|
||||
if status == "deployed" {
|
||||
appNames = append(appNames, app.Name)
|
||||
}
|
||||
}
|
||||
|
||||
return appNames, nil
|
||||
}
|
||||
|
||||
// CopyAppEnvSample copies the example env file for the app into the users env files
|
||||
func CopyAppEnvSample(appType, appName, server string) error {
|
||||
envSamplePath := path.Join(ABRA_DIR, "apps", appType, ".env.sample")
|
||||
|
|
Loading…
Reference in New Issue