mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-27 20:09:39 -08:00
refactor: do not merge settings
This feature no longer serves its purpose
This commit is contained in:
parent
2603ff51bf
commit
8a3f330af4
9
Gopkg.lock
generated
9
Gopkg.lock
generated
|
@ -27,14 +27,6 @@
|
||||||
revision = "c52faac6396f15fd78c8fd343657f514b60a1147"
|
revision = "c52faac6396f15fd78c8fd343657f514b60a1147"
|
||||||
source = "github.com/JanDeDobbeleer/color"
|
source = "github.com/JanDeDobbeleer/color"
|
||||||
|
|
||||||
[[projects]]
|
|
||||||
digest = "1:eba10af56a904e7d797ccbdca4a6fae4029537b0118b6582f9f93e025b86af2a"
|
|
||||||
name = "github.com/imdario/mergo"
|
|
||||||
packages = ["."]
|
|
||||||
pruneopts = "UT"
|
|
||||||
revision = "cd55aeac72a19c6d5826061d5125d72b252a12eb"
|
|
||||||
version = "v0.3.11"
|
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
digest = "1:69530a15507094162be4eb3180c1d68b787177e8c9bbe76d4da40d44d6586f6f"
|
digest = "1:69530a15507094162be4eb3180c1d68b787177e8c9bbe76d4da40d44d6586f6f"
|
||||||
name = "github.com/mitchellh/go-ps"
|
name = "github.com/mitchellh/go-ps"
|
||||||
|
@ -122,7 +114,6 @@
|
||||||
input-imports = [
|
input-imports = [
|
||||||
"github.com/distatus/battery",
|
"github.com/distatus/battery",
|
||||||
"github.com/gookit/color",
|
"github.com/gookit/color",
|
||||||
"github.com/imdario/mergo",
|
|
||||||
"github.com/mitchellh/go-ps",
|
"github.com/mitchellh/go-ps",
|
||||||
"github.com/stretchr/testify/assert",
|
"github.com/stretchr/testify/assert",
|
||||||
"github.com/stretchr/testify/mock",
|
"github.com/stretchr/testify/mock",
|
||||||
|
|
|
@ -34,10 +34,6 @@
|
||||||
name = "golang.org/x/text"
|
name = "golang.org/x/text"
|
||||||
source = "golang.org/x/text"
|
source = "golang.org/x/text"
|
||||||
|
|
||||||
[[constraint]]
|
|
||||||
version = "v0.3.7"
|
|
||||||
name = "github.com/imdario/mergo"
|
|
||||||
|
|
||||||
[[constraint]]
|
[[constraint]]
|
||||||
name = "github.com/stretchr/testify"
|
name = "github.com/stretchr/testify"
|
||||||
version = "1.3.0"
|
version = "1.3.0"
|
||||||
|
|
19
settings.go
19
settings.go
|
@ -4,8 +4,6 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/imdario/mergo"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//Settings holds all the theme for rendering the prompt
|
//Settings holds all the theme for rendering the prompt
|
||||||
|
@ -45,15 +43,16 @@ type Block struct {
|
||||||
|
|
||||||
//GetSettings returns the default configuration including possible user overrides
|
//GetSettings returns the default configuration including possible user overrides
|
||||||
func GetSettings(env environmentInfo) *Settings {
|
func GetSettings(env environmentInfo) *Settings {
|
||||||
defaultSettings := getDefaultSettings()
|
settings, err := loadUserConfiguration(env)
|
||||||
settings := loadUserConfiguration(env)
|
if err != nil {
|
||||||
_ = mergo.Merge(settings, defaultSettings)
|
return getDefaultSettings()
|
||||||
|
}
|
||||||
return settings
|
return settings
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadUserConfiguration(env environmentInfo) *Settings {
|
func loadUserConfiguration(env environmentInfo) (*Settings, error) {
|
||||||
var settings Settings
|
var settings Settings
|
||||||
settingsFileLocation := fmt.Sprintf("%s/.go_my_psh", env.getenv("HOME"))
|
settingsFileLocation := fmt.Sprintf("%s/.go_my_posh", env.getenv("HOME"))
|
||||||
if _, err := os.Stat(*env.getArgs().Config); !os.IsNotExist(err) {
|
if _, err := os.Stat(*env.getArgs().Config); !os.IsNotExist(err) {
|
||||||
settingsFileLocation = *env.getArgs().Config
|
settingsFileLocation = *env.getArgs().Config
|
||||||
}
|
}
|
||||||
|
@ -62,11 +61,11 @@ func loadUserConfiguration(env environmentInfo) *Settings {
|
||||||
_ = defaultSettings.Close()
|
_ = defaultSettings.Close()
|
||||||
}()
|
}()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &settings
|
return nil, err
|
||||||
}
|
}
|
||||||
jsonParser := json.NewDecoder(defaultSettings)
|
jsonParser := json.NewDecoder(defaultSettings)
|
||||||
_ = jsonParser.Decode(&settings)
|
err = jsonParser.Decode(&settings)
|
||||||
return &settings
|
return &settings, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDefaultSettings() *Settings {
|
func getDefaultSettings() *Settings {
|
||||||
|
|
Loading…
Reference in a new issue