From 180e85c55f2f27430c02edd3fd053ff3377f7886 Mon Sep 17 00:00:00 2001 From: Luiz Branco Date: Fri, 27 Jul 2018 09:43:24 -0300 Subject: [PATCH 1/2] User XDG_CONFIG_HOME if available for manifoldrc --- config/config.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/config/config.go b/config/config.go index 0078aad..9cfd71e 100644 --- a/config/config.go +++ b/config/config.go @@ -35,7 +35,7 @@ const ( defaultHostname = "manifold.co" defaultScheme = "https" defaultAnalytics = true - rcFilename = ".manifoldrc" + rcFilename = "manifoldrc" // YamlFilename is where dirprefs are stored YamlFilename = ".manifold.yml" ) @@ -122,13 +122,24 @@ func loadConfigurationCheckLegacy() (*Config, error) { return cfg, nil } -// RCPath returns the absolute path to the ~/.manifoldrc file +// RCPath returns the absolute path to the manifoldrc file. If XDG_CONFIG_HOME +// is defined returns $XDG_CONFIG_HOME/manifold/manifoldrc othewise it returns +// $HOME/.manifoldrc func RCPath() (string, error) { + home := os.Getenv("XDG_CONFIG_HOME") + if home != "" { + err := os.MkdirAll(path.Join(home, "manifold"), 0700) + if err != nil { + return "", err + } + return path.Join(home, "manifold", rcFilename), nil + } + home, err := UserHome() if err != nil { return "", err } - return path.Join(home, rcFilename), nil + return path.Join(home, "."+rcFilename), nil } // Config represents the configuration which is stored inside a ~/.manifoldrc From 816dd1011a5dd97176dfbfe24bf0df6d71a08a79 Mon Sep 17 00:00:00 2001 From: Luiz Branco Date: Fri, 27 Jul 2018 10:43:57 -0300 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56e2361..5b9bcd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Unreleased +### Added + +- Support for `XDG_CONFIG_HOME` will take precedence over `~/.manifoldrc` for + reading and writing the config file + ## [0.15.1] - 2018-07-25 ### Fixed