feat: add app config command
This commit is contained in:
parent
0825321b26
commit
acca710a5a
2
TODO.md
2
TODO.md
@ -18,7 +18,7 @@
|
|||||||
- [ ] `deploy` (WIP: decentral1se)
|
- [ ] `deploy` (WIP: decentral1se)
|
||||||
- [x] `check`
|
- [x] `check`
|
||||||
- [x] `version`
|
- [x] `version`
|
||||||
- [ ] `config` (WIP: decentral1se)
|
- [x] `config`
|
||||||
- [ ] `cp`
|
- [ ] `cp`
|
||||||
- [ ] `logs`
|
- [ ] `logs`
|
||||||
- [x] `ps`
|
- [x] `ps`
|
||||||
|
@ -1,7 +1,50 @@
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
import "github.com/urfave/cli/v2"
|
import (
|
||||||
|
"errors"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
|
||||||
|
"coopcloud.tech/abra/cli/internal"
|
||||||
|
"coopcloud.tech/abra/config"
|
||||||
|
"github.com/AlecAivazis/survey/v2"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
|
)
|
||||||
|
|
||||||
var appConfigCommand = &cli.Command{
|
var appConfigCommand = &cli.Command{
|
||||||
Name: "config",
|
Name: "config",
|
||||||
|
Usage: "edit app environment config",
|
||||||
|
Action: func(c *cli.Context) error {
|
||||||
|
appName := c.Args().First()
|
||||||
|
if appName == "" {
|
||||||
|
internal.ShowSubcommandHelpAndError(c, errors.New("no app name provided"))
|
||||||
|
}
|
||||||
|
|
||||||
|
ed, ok := os.LookupEnv("EDITOR")
|
||||||
|
if !ok {
|
||||||
|
edPrompt := &survey.Select{
|
||||||
|
Message: "Which editor do you wish to use?",
|
||||||
|
Options: []string{"vi", "vim", "nvim", "nano", "pico", "emacs"},
|
||||||
|
}
|
||||||
|
if err := survey.AskOne(edPrompt, &ed); err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
cmd.Stderr = os.Stderr
|
||||||
|
if err := cmd.Run(); err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user