diff --git a/argset.go b/argset.go index dd54cbc..9ccb0b5 100755 --- a/argset.go +++ b/argset.go @@ -42,6 +42,26 @@ func (as *ArgSet) Get(key string) *Arg { return nil } +func (as *ArgSet) GetInt(key string) int { + a := as.Get(key) + return a.GetInt() +} + +func (as *ArgSet) GetBool(key string) bool { + a := as.Get(key) + return a.GetBool() +} + +func (as *ArgSet) GetDuration(key string) time.Duration { + a := as.Get(key) + return a.GetDuration() +} + +func (as *ArgSet) GetString(key string) string { + a := as.Get(key) + return a.GetString() +} + func (as *ArgSet) Parse() error { if as.parsed { return nil @@ -78,6 +98,7 @@ func (as *ArgSet) setValueFromDefaults() error { func (as *ArgSet) setValueFromEnv() error { for i := range as.args { key := as.args[i].Env + key = strings.ReplaceAll(key, "-", "_") if v, ok := os.LookupEnv(key); ok { if err := as.args[i].Set(v); err != nil { return err