Compare commits
5 Commits
chore-deps
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
bda51f2fef
|
|||
|
55e794e45a
|
|||
| 26293a47e7 | |||
| 0ec57a11bd | |||
| 2f4778e600 |
@@ -0,0 +1,4 @@
|
||||
# You can change your abra-main folder here
|
||||
#abraDir: $HOME
|
||||
# Set your favorite editor here
|
||||
#editor: nano
|
||||
+4
-3
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
appPkg "coopcloud.tech/abra/pkg/app"
|
||||
"coopcloud.tech/abra/pkg/autocomplete"
|
||||
"coopcloud.tech/abra/pkg/config"
|
||||
"coopcloud.tech/abra/pkg/i18n"
|
||||
"coopcloud.tech/abra/pkg/log"
|
||||
"github.com/AlecAivazis/survey/v2"
|
||||
@@ -43,8 +44,8 @@ var AppConfigCommand = &cobra.Command{
|
||||
log.Fatal(i18n.G("cannot find app with name %s", appName))
|
||||
}
|
||||
|
||||
ed, ok := os.LookupEnv("EDITOR")
|
||||
if !ok {
|
||||
ed := config.EDITOR
|
||||
if ed=="" {
|
||||
edPrompt := &survey.Select{
|
||||
Message: i18n.G("which editor do you wish to use?"),
|
||||
Options: []string{"vi", "vim", "nvim", "nano", "pico", "emacs"},
|
||||
@@ -53,7 +54,7 @@ var AppConfigCommand = &cobra.Command{
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
log.Debug(i18n.G("editor used: %s",ed))
|
||||
c := exec.Command(ed, appFile.Path)
|
||||
c.Stdin = os.Stdin
|
||||
c.Stdout = os.Stdout
|
||||
|
||||
+19
-1
@@ -66,6 +66,24 @@ func findAbraConfig(dir string) string {
|
||||
type Abra struct {
|
||||
configPath string
|
||||
AbraDir string `yaml:"abraDir"`
|
||||
Editor string `yaml:"editor"`
|
||||
}
|
||||
|
||||
// GetEditor returns the user's prefered edtor. It has the following logic:
|
||||
// 1. check if $EDITor is set
|
||||
// 2. check if EDITOR was set in a config file
|
||||
// 3. let the user select editor when editing .env-files.
|
||||
func (a Abra) GetEditor() string {
|
||||
if editor, exists := os.LookupEnv("EDITOR"); exists && editor != "" {
|
||||
log.Debug(i18n.G("read editor from $EDITOR"))
|
||||
return editor
|
||||
}
|
||||
if a.Editor != "" {
|
||||
log.Debug(i18n.G("read editor from config file"))
|
||||
return a.Editor
|
||||
}
|
||||
log.Debug(i18n.G("no editor chosen"))
|
||||
return ""
|
||||
}
|
||||
|
||||
// GetAbraDir returns the abra dir. It has the following logic:
|
||||
@@ -107,7 +125,7 @@ var (
|
||||
CATALOGUE_JSON_REPO_NAME = "recipes-catalogue-json"
|
||||
TOOLSHED_SSH_URL_TEMPLATE = "ssh://git@git.coopcloud.tech:2222/toolshed/%s.git"
|
||||
RECIPES_SSH_URL_TEMPLATE = "ssh://git@git.coopcloud.tech:2222/coop-cloud/%s.git"
|
||||
|
||||
EDITOR = config.GetEditor()
|
||||
// NOTE(d1): please note, this was done purely out of laziness on our part
|
||||
// AFAICR. it's easy to punt the value into the label because that is what is
|
||||
// expects. it's not particularly useful in terms of UI/UX but hey, nobody
|
||||
|
||||
Reference in New Issue
Block a user