-
Notifications
You must be signed in to change notification settings - Fork 0
/
funcs.go
110 lines (103 loc) · 3.1 KB
/
funcs.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package gokwallet
import (
"errors"
)
/*
NewRecurseOpts returns a RecurseOpts based on the specified options.
See the documentation for RecurseOpts for descriptions of the behaviour for each recursion option.
warn is a MultiError but should be treated as warnings rather than strictly errors.
*/
func NewRecurseOpts(recurseAll, wallets, folders, recurseAllWalletItems, passwords, maps, blobs, unknownItems bool) (opts *RecurseOpts, warn error) {
var err []error = make([]error, 0)
if recurseAll {
if !wallets {
err = append(err, errors.New("wallets was specified as false but recurseAll is true; recurseAll overrides wallets to true"))
wallets = true
}
if !folders {
err = append(err, errors.New("folders was specified as false but recurseAll is true; recurseAll overrides folders to true"))
folders = true
}
// NOTE: This is commented out because we control these explicitly with recurseAllWalletItems.
/*
if !passwords {
err = append(err, errors.New("passwords was specified as false but recurseAll is true; recurseAll overrides passwords to true"))
passwords = true
}
if !maps {
err = append(err, errors.New("maps was specified as false but recurseAll is true; recurseAll overrides maps to true"))
maps = true
}
if !blobs {
err = append(err, errors.New("blobs was specified as false but recurseAll is true; recurseAll overrides blobs to true"))
blobs = true
}
if !unknownItems {
err = append(err, errors.New("unknownItems was specified as false but recurseAll is true; recurseAll overrides unknownItems to true"))
unknownItems = true
}
if !recurseAllWalletItems {
err = append(
err,
errors.New(
"recurseAllWalletItems was specified as false but recurseAll is true; recurseAll overrides recurseAllWalletItems to true",
),
)
recurseAllWalletItems = true
}
*/
} else {
if recurseAllWalletItems {
if !passwords {
err = append(
err,
errors.New(
"passwords was specified as false but recurseAllWalletItems is true; recurseAllWalletItems overrides passwords to true",
),
)
passwords = true
}
if !maps {
err = append(
err,
errors.New(
"maps was specified as false but recurseAllWalletItems is true; recurseAllWalletItems overrides maps to true",
),
)
maps = true
}
if !blobs {
err = append(
err,
errors.New(
"blobs was specified as false but recurseAllWalletItems is true; recurseAllWalletItems overrides blobs to true",
),
)
blobs = true
}
if !unknownItems {
err = append(
err,
errors.New(
"unknownItems was specified as false but recurseAllWalletItems is true; recurseAllWalletItems overrides unknownItems to true",
),
)
unknownItems = true
}
}
}
opts = &RecurseOpts{
All: recurseAll,
Wallets: wallets,
Folders: folders,
AllWalletItems: recurseAllWalletItems,
Passwords: passwords,
Maps: maps,
Blobs: blobs,
UnknownItems: unknownItems,
}
if err != nil && len(err) > 0 {
warn = NewErrors(err...)
}
return
}