feat: auto-complete app and recipe names #89

Merged
decentral1se merged 3 commits from knoflook/abra:main into main 2021-09-08 12:16:42 +00:00
6 changed files with 8 additions and 30 deletions
Showing only changes of commit cf2653fef8 - Show all commits

View File

@ -111,7 +111,7 @@ var appLogsCommand = &cli.Command{
return nil
},
BashComplete: func(c *cli.Context) {
appNames, err := config.GetAppsNames()
appNames, err := config.GetAppNames()
if err != nil {
return
}

View File

@ -57,7 +57,7 @@ var appPsCommand = &cli.Command{
return nil
},
BashComplete: func(c *cli.Context) {
appNames, err := config.GetAppsNames()
appNames, err := config.GetAppNames()
if err != nil {
return
}

View File

@ -156,7 +156,7 @@ var appRemoveCommand = &cli.Command{
return nil
},
BashComplete: func(c *cli.Context) {
appNames, err := config.GetAppsNames()
appNames, err := config.GetAppNames()
if err != nil {
return
}

View File

@ -38,7 +38,7 @@ volumes as eligiblef or pruning once undeployed.
return nil
},
BashComplete: func(c *cli.Context) {
appNames, err := config.GetDeployedApps()
appNames, err := config.GetAppNames()
knoflook marked this conversation as resolved Outdated

Given coop-cloud/abra#87 (comment) I guess we can just do config.GetAppsNames and call it a day?

Given https://git.coopcloud.tech/coop-cloud/abra/issues/87#issuecomment-8528 I guess we can just do `config.GetAppsNames` and call it a day?
if err != nil {
return
}

View File

@ -84,7 +84,7 @@ var appVolumeRemoveCommand = &cli.Command{
return nil
},
BashComplete: func(c *cli.Context) {
appNames, err := config.GetAppsNames()
appNames, err := config.GetAppNames()
if err != nil {
return
}

View File

@ -177,14 +177,14 @@ func GetApps(appFiles AppFiles) ([]App, error) {
return apps, nil
}
func GetAppsNames() ([]string, error) {
func GetAppNames() ([]string, error) {
knoflook marked this conversation as resolved Outdated

Maybe a nitpick but GetAppNames is easier to say 😀 (ignore ofc if you don't mind it)

Maybe a nitpick but `GetAppNames` is easier to say 😀 (ignore ofc if you don't mind it)
appFiles, err := LoadAppFiles("")
if err != nil {
return nil, err
return []string{}, err
knoflook marked this conversation as resolved Outdated

return []string{}, err to pass an empty list and avoid nil errors somewhere else?

`return []string{}, err` to pass an empty list and avoid nil errors somewhere else?
}
apps, err := GetApps(appFiles)
if err != nil {
return nil, err
return []string{}, err
}
var appNames []string
@ -195,28 +195,6 @@ func GetAppsNames() ([]string, error) {
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
knoflook marked this conversation as resolved Outdated

Yeah I guess we don't need this now but maybe keep it?

idk, could also just end up lurking there without being used 🤔

Yeah I guess we don't need this now but maybe keep it? idk, could also just end up lurking there without being used 🤔

It's simple enought to rewrite so might as well get rid of it

It's simple enought to rewrite so might as well get rid of it
func CopyAppEnvSample(appType, appName, server string) error {
envSamplePath := path.Join(ABRA_DIR, "apps", appType, ".env.sample")