alecthomas / kingpin

CONTRIBUTIONS ONLY: A Go (golang) command line and flag parser
MIT License
3.5k stars 273 forks source link

Expand DurationVar to support days and weeks #328

Closed adowair closed 2 years ago

adowair commented 2 years ago

Today, Kingpin's DurationVar() uses time.ParseDuration() to parse duration strings. Unfortunately, time.ParseDuration does not parse durations that contain days ("d") or weeks ("w"). It'd be great to expand the implementation to support them by using str2duration.ParseDuration() from https://github.com/xhit/go-str2duration instead.