alecthomas / alecthomas/kingpin

PreAction does not trigger on a flag when it is specified by an env variable.

Open
#175 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
3.6k
Forks
279
PR merge metrics
No merged PRs in 30d

Description

```
var enabled bool
cmd.Flag("profiler-enable", "enable the profiler").Default("false").
Envar("PROFILER_ENABLED").PreAction(execute).BoolVar(&enabled)

func execute(c *kingpin.ParseContext) error {
log.Println("enabling profiler")
return nil
}
```

```
spike --profiler-enable
# enabling profiler
```

```
PROFILER_ENABLED=true spike
# nothing output
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.