From 52bd32914a6184ee4d403f8418eb0546074ac5bb Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Sat, 18 Mar 2023 13:48:41 +0100 Subject: Print metrics based on flag duration to stderr --- internal/ctflag/ctflag.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'internal') diff --git a/internal/ctflag/ctflag.go b/internal/ctflag/ctflag.go index 1309afd..cf8d7db 100644 --- a/internal/ctflag/ctflag.go +++ b/internal/ctflag/ctflag.go @@ -31,6 +31,7 @@ package ctflag import ( "flag" "fmt" + "time" ) // NewFlagSet outputs a new flag set that continues on errors without standard @@ -77,6 +78,12 @@ func Uint64(fs *flag.FlagSet, opt *uint64, short, long string, value uint64) { fs.Uint64Var(opt, long, value, "") } +// Duration adds a new duration option to a flag set +func Duration(fs *flag.FlagSet, opt *time.Duration, short, long string, value time.Duration) { + fs.DurationVar(opt, short, value, "") + fs.DurationVar(opt, long, value, "") +} + // Bool adds a new bool option to a flag set func Bool(fs *flag.FlagSet, opt *bool, short, long string, value bool) { fs.BoolVar(opt, short, value, "") -- cgit v1.2.3