forked from toolshed/abra
Compare commits
6 Commits
fix/deps
...
editorconf
| Author | SHA1 | Date | |
|---|---|---|---|
|
bda51f2fef
|
|||
|
55e794e45a
|
|||
| 26293a47e7 | |||
| 0ec57a11bd | |||
| 2f4778e600 | |||
| 5b3929d885 |
4
abra.yml
Normal file
4
abra.yml
Normal file
@ -0,0 +1,4 @@
|
||||
# You can change your abra-main folder here
|
||||
#abraDir: $HOME
|
||||
# Set your favorite editor here
|
||||
#editor: nano
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -89,7 +89,7 @@ function install_abra_release {
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "$(tput setaf 3)WARNING: $HOME/.local/bin/ is not in \$PATH! If you want to run abra by just typing "abra" you should add it to your \$PATH! To do that run this once and restart your terminal:$(tput sgr0)"
|
||||
p=$HOME/.local/bin
|
||||
com="echo PATH=\$PATH:$p"
|
||||
com='echo PATH="$PATH:'"$p"'"'
|
||||
if [[ $SHELL =~ "bash" ]]; then
|
||||
echo "$com >> $HOME/.bashrc"
|
||||
elif [[ $SHELL =~ "fizsh" ]]; then
|
||||
|
||||
Reference in New Issue
Block a user