Skip to content

Commit

Permalink
Use the configuration location of the user's OS. Fixes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
a-h committed Sep 20, 2020
1 parent 249ecd0 commit 7403144
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ Ctrl-D Scroll down half a screen

### config.ini

* Stored at $HOME/.min/config.ini
* Stored in your operating system's default config location under .min, e.g.
* Linux: $HOME/config/.min/config.ini
* Mac: ~/Library/Application Support/.min/config.ini
* Windows: %AppData%/.min/config.ini
* Consists of key/value pairs (e.g. "width=80")
* Contains previously accepted server certificates
* Contains links to client certificates, stored in the same directory
Expand Down
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ func (cc ClientCertPrefix) Save(cert, key []byte) error {
}

var configPath = func() string {
home, _ := os.UserHomeDir()
return path.Join(home, ".min")
configPath, _ := os.UserConfigDir()
return path.Join(configPath, ".min")
}()

type Config struct {
Expand All @@ -76,7 +76,6 @@ func (c *Config) Save() error {
fmt.Fprintf(b, "hostcert/%v=%v\n", host, cert)
}
fn := path.Join(configPath, "config.ini")
os.MkdirAll(path.Dir(fn), os.ModePerm)
return atomic.WriteFile(fn, b)
}

Expand All @@ -88,6 +87,7 @@ func NewConfig() (c *Config, err error) {
HostCertificates: map[string]string{},
ClientCertPrefixes: map[ClientCertPrefix]struct{}{},
}
os.MkdirAll(configPath, os.ModePerm)
lines, err := readLines(path.Join(configPath, "config.ini"))
if err != nil {
return
Expand Down

0 comments on commit 7403144

Please sign in to comment.