From f21d4fc496a621f350aea6d11d302c7f23ba46ea Mon Sep 17 00:00:00 2001 From: Diff Date: Fri, 13 Nov 2020 05:45:01 +0000 Subject: [PATCH] Added flag to "get" subcommand to configure venture freshness limit --- main.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 63e82a0..3d4f98a 100644 --- a/main.go +++ b/main.go @@ -36,8 +36,11 @@ func main() { // GetVenture collects all recent ventures from all users on the system. // Any errors that occur while pulling individual ventures are silently ignored func GetVenture(args []string) error { - // Set the expiration date for ventures at 2 weeks. - freshLimit := time.Now().AddDate(0, 0, -14) + getFlags := flag.NewFlagSet(os.Args[0]+" get", flag.ExitOnError) + freshDays := getFlags.Int("freshness", 14, "get all ventures newer than this number of days") + getFlags.Parse(args) + + freshLimit := time.Now().AddDate(0, 0, *freshDays*-1) allVenturePaths, err := filepath.Glob("/home/*/.venture") if err != nil {