Don't fail on required positional arguments that have envars.

Fixes #153.
Fixes #120.
This commit is contained in:
Alec Thomas
2021-06-21 17:11:10 +09:30
parent a8244400e3
commit 8aa52739ea
3 changed files with 50 additions and 1 deletions
+12 -1
View File
@@ -820,7 +820,18 @@ func checkMissingPositionals(positional int, values []*Value) error {
missing := []string{}
for ; positional < len(values); positional++ {
missing = append(missing, "<"+values[positional].Name+">")
arg := values[positional]
// TODO(aat): Fix hardcoding of these env checks all over the place :\
if arg.Tag.Env != "" {
_, ok := os.LookupEnv(arg.Tag.Env)
if ok {
continue
}
}
missing = append(missing, "<"+arg.Name+">")
}
if len(missing) == 0 {
return nil
}
return fmt.Errorf("missing positional arguments %s", strings.Join(missing, " "))
}