refactor: use app getting instead of boilerplate

This commit is contained in:
2021-09-05 23:17:35 +02:00
parent 48bcc9cb36
commit d4333c2dc0
18 changed files with 111 additions and 266 deletions

View File

@ -5,7 +5,6 @@ import (
"os/exec"
"coopcloud.tech/abra/cli/internal"
"coopcloud.tech/abra/pkg/config"
"github.com/AlecAivazis/survey/v2"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
@ -16,16 +15,7 @@ var appConfigCommand = &cli.Command{
Aliases: []string{"c"},
Usage: "Edit app config",
Action: func(c *cli.Context) error {
appName := internal.ValidateAppNameArg(c)
appFiles, err := config.LoadAppFiles("")
if err != nil {
logrus.Fatal(err)
}
if _, ok := appFiles[appName]; !ok {
logrus.Fatalf("'%s' doesn't exist?", appName)
}
app := internal.ValidateApp(c)
ed, ok := os.LookupEnv("EDITOR")
if !ok {
@ -38,7 +28,7 @@ var appConfigCommand = &cli.Command{
}
}
cmd := exec.Command(ed, appFiles[appName].Path)
cmd := exec.Command(ed, app.Path)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr