Skip to content

Commit

Permalink
feat: allow use system enviroment variables
Browse files Browse the repository at this point in the history
windwp authored May 5, 2022
1 parent 3399f02 commit 73fed62
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
@@ -67,6 +67,10 @@ func ParseConfig(data string, settings map[string]string) (Config, error) {
return val
}

if val, ok := os.LookupEnv(v); ok {
return val
}

return v
})

4 changes: 3 additions & 1 deletion config_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"os"
"reflect"
"testing"
)
@@ -15,6 +16,7 @@ windows:
panes:
- commands:
- echo 2
- echo ${HOME}
type: horizontal`

config, err := ParseConfig(yaml, map[string]string{
@@ -33,7 +35,7 @@ windows:
Panes: []Pane{
{
Type: "horizontal",
Commands: []string{"echo 2"},
Commands: []string{"echo 2", "echo " + os.Getenv("HOME")},
},
},
},

0 comments on commit 73fed62

Please sign in to comment.