From 60a720f0c505eb5035ccc50cfbb67b7b66e34cb1 Mon Sep 17 00:00:00 2001 From: ayntgl Date: Thu, 17 Mar 2022 20:04:24 +0400 Subject: [PATCH] fix: add default config var to kong --- config/pkg.go | 4 +--- main.go | 8 +++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/config/pkg.go b/config/pkg.go index f7c3b01..798fb9a 100644 --- a/config/pkg.go +++ b/config/pkg.go @@ -9,7 +9,7 @@ import ( type Config struct { Token string `toml:"-" name:"token" help:"The authentication token." short:"T"` - Config string `toml:"-" name:"config" help:"The path of the configuration file." type:"path" short:"C"` + Config string `toml:"-" name:"config" help:"The path of the configuration file." default:"${config}" type:"path" short:"C"` General GeneralConfig `toml:"general" kong:"-"` Theme ThemeConfig `toml:"theme" kong:"-"` @@ -18,8 +18,6 @@ type Config struct { func New() *Config { return &Config{ - Config: DefaultPath(), - General: newGeneralConfig(), Theme: newThemeConfig(), Keys: newKeysConfig(), diff --git a/main.go b/main.go index 655f98d..3955166 100644 --- a/main.go +++ b/main.go @@ -14,7 +14,13 @@ const name = "discordo" func main() { cfg := config.New() - kong.Parse(cfg, kong.Name(name), kong.UsageOnError()) + kong.Parse(cfg, + kong.Name(name), + kong.UsageOnError(), + kong.Vars{ + "config": config.DefaultPath(), + }, + ) if cfg.Token == "" { cfg.Token, _ = keyring.Get(name, "token")