fix: bail out if app doesn't exist
continuous-integration/drone/push Build is passing Details

Closes coop-cloud/go-abra#67.
Closes coop-cloud/go-abra#69.

Fix lifted from approach in
coop-cloud/go-abra#69. Thanks for
@knoflook!
This commit is contained in:
decentral1se 2021-09-05 21:46:36 +02:00
parent d82f854ebd
commit 273db078b0
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
1 changed files with 9 additions and 5 deletions

View File

@ -22,6 +22,15 @@ var appConfigCommand = &cli.Command{
internal.ShowSubcommandHelpAndError(c, errors.New("no app name provided"))
}
appFiles, err := config.LoadAppFiles("")
if err != nil {
logrus.Fatal(err)
}
if _, ok := appFiles[appName]; !ok {
logrus.Fatalf("'%s' doesn't exist?", appName)
}
ed, ok := os.LookupEnv("EDITOR")
if !ok {
edPrompt := &survey.Select{
@ -33,11 +42,6 @@ var appConfigCommand = &cli.Command{
}
}
appFiles, err := config.LoadAppFiles("")
if err != nil {
logrus.Fatal(err)
}
cmd := exec.Command(ed, appFiles[appName].Path)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout