fix: add default config var to kong
This commit is contained in:
parent
252548606b
commit
60a720f0c5
2 changed files with 8 additions and 4 deletions
|
|
@ -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(),
|
||||
|
|
|
|||
8
main.go
8
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")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue