summaryrefslogtreecommitdiff
path: root/cmd/krino/common.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/krino/common.go')
-rw-r--r--cmd/krino/common.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/cmd/krino/common.go b/cmd/krino/common.go
index ea1e83d..4552441 100644
--- a/cmd/krino/common.go
+++ b/cmd/krino/common.go
@@ -6,11 +6,37 @@ import (
"fmt"
"io"
"strings"
+ "time"
"krino/internal/config"
+ "krino/internal/engine"
"krino/internal/xdg"
)
+// minAgeOverride parses --min-age: a duration in krino's own units (30s,
+// 2m, 1h, 1d, 1w), or a bare 0. set is false when the flag was not given.
+// Checked before any config is read, as every flag is.
+func minAgeOverride(g *globals) (d time.Duration, set bool, err error) {
+ switch g.minAge {
+ case "":
+ return 0, false, nil
+ case "0":
+ return 0, true, nil
+ }
+ d, err = config.ParseDuration(g.minAge)
+ if err != nil {
+ return 0, false, fmt.Errorf("--min-age: %v", err)
+ }
+ return d, true, nil
+}
+
+// applyMinAge sets every loaded directory's min-age to d, for this run only.
+func applyMinAge(e *engine.Engine, d time.Duration) {
+ for _, dir := range e.Dirs {
+ dir.Settings.MinAge = d
+ }
+}
+
// mainFile is -c FILE, or the default krino.conf.
func mainFile(g *globals) string {
if g.conf != "" {