forked from gopasspw/gopass
/
context.go
31 lines (28 loc) · 810 Bytes
/
context.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package config
import (
"context"
"github.com/gopasspw/gopass/pkg/ctxutil"
)
// WithContext returns a context with all config options set for this store
// config, iff they have not been already set in the context
func (c *Config) WithContext(ctx context.Context) context.Context {
if !c.AutoImport {
ctx = ctxutil.WithImportFunc(ctx, nil)
}
if !ctxutil.HasExportKeys(ctx) {
ctx = ctxutil.WithExportKeys(ctx, c.ExportKeys)
}
if !ctxutil.HasNoPager(ctx) {
ctx = ctxutil.WithNoPager(ctx, c.NoPager)
}
if !ctxutil.HasNotifications(ctx) {
ctx = ctxutil.WithNotifications(ctx, c.Notifications)
}
if !ctxutil.HasShowSafeContent(ctx) {
ctx = ctxutil.WithShowSafeContent(ctx, c.SafeContent)
}
if !ctxutil.HasShowParsing(ctx) {
ctx = ctxutil.WithShowParsing(ctx, c.Parsing)
}
return ctx
}