Compare commits

...

5 Commits

Author SHA1 Message Date
jeppebundsgaard bda51f2fef Add editor as config 2026-01-13 23:41:20 +01:00
jeppebundsgaard 55e794e45a Add editor as config 2026-01-13 23:24:19 +01:00
jeppebundsgaard 26293a47e7 Update abra.yml 2026-01-04 22:22:48 +00:00
jeppebundsgaard 0ec57a11bd Sample config 2026-01-04 22:18:10 +00:00
jeppebundsgaard 2f4778e600 Added editor as config setting 2026-01-04 22:03:42 +00:00
3 changed files with 27 additions and 4 deletions
+4
View File
@@ -0,0 +1,4 @@
# You can change your abra-main folder here
#abraDir: $HOME
# Set your favorite editor here
#editor: nano
+4 -3
View File
@@ -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
View File
@@ -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