mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 12:28:09 +01:00
go: use a different goconfig package
The notmuch-addrlookup utility uses a third party library to read the notmuch configuration file. The previously used implementation at "github.com/kless/goconfig" vanished, so this patch switches to the implementation at "github.com/msbranco/goconfig". As the implementations differ at the API level, the code is updated accordingly. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
This commit is contained in:
parent
51b073c6f2
commit
44fe1f2c16
2 changed files with 8 additions and 10 deletions
|
@ -15,8 +15,8 @@ notmuch:
|
||||||
|
|
||||||
.PHONY: goconfig
|
.PHONY: goconfig
|
||||||
goconfig:
|
goconfig:
|
||||||
if [ ! -d src/github.com/kless/goconfig/config ]; then \
|
if [ ! -d github.com/msbranco/goconfig ]; then \
|
||||||
$(GO) get github.com/kless/goconfig/config; \
|
$(GO) get github.com/msbranco/goconfig; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
.PHONY: notmuch-addrlookup
|
.PHONY: notmuch-addrlookup
|
||||||
|
|
|
@ -11,7 +11,7 @@ import "sort"
|
||||||
|
|
||||||
// 3rd-party imports
|
// 3rd-party imports
|
||||||
import "notmuch"
|
import "notmuch"
|
||||||
import "github.com/kless/goconfig/config"
|
import "github.com/msbranco/goconfig"
|
||||||
|
|
||||||
type mail_addr_freq struct {
|
type mail_addr_freq struct {
|
||||||
addr string
|
addr string
|
||||||
|
@ -178,22 +178,20 @@ type address_matcher struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func new_address_matcher() *address_matcher {
|
func new_address_matcher() *address_matcher {
|
||||||
var cfg *config.Config
|
|
||||||
var err error
|
|
||||||
|
|
||||||
// honor NOTMUCH_CONFIG
|
// honor NOTMUCH_CONFIG
|
||||||
home := os.Getenv("NOTMUCH_CONFIG")
|
home := os.Getenv("NOTMUCH_CONFIG")
|
||||||
if home == "" {
|
if home == "" {
|
||||||
home = os.Getenv("HOME")
|
home = os.Getenv("HOME")
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg, err = config.ReadDefault(path.Join(home, ".notmuch-config")); err != nil {
|
cfg, err := goconfig.ReadConfigFile(path.Join(home, ".notmuch-config"))
|
||||||
|
if err != nil {
|
||||||
log.Fatalf("error loading config file:", err)
|
log.Fatalf("error loading config file:", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
db_path, _ := cfg.String("database", "path")
|
db_path, _ := cfg.GetString("database", "path")
|
||||||
primary_email, _ := cfg.String("user", "primary_email")
|
primary_email, _ := cfg.GetString("user", "primary_email")
|
||||||
addrbook_tag, err := cfg.String("user", "addrbook_tag")
|
addrbook_tag, err := cfg.GetString("user", "addrbook_tag")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
addrbook_tag = "addressbook"
|
addrbook_tag = "addressbook"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue