6
6
"fmt"
7
7
"github.com/pythonhacker/argparse"
8
8
"os"
9
+ "strings"
9
10
)
10
11
11
12
const VERSION = 0.3
@@ -86,13 +87,16 @@ func performAction(optMap map[string]interface{}) {
86
87
"edit" : WrapperMaxKryptStringFunc (editCurrentEntry ),
87
88
"init" : initNewDatabase ,
88
89
"list-entry" : WrapperMaxKryptStringFunc (listCurrentEntry ),
89
- "find" : WrapperMaxKryptStringFunc (findCurrentEntry ),
90
90
"remove" : WrapperMaxKryptStringFunc (removeCurrentEntry ),
91
91
"clone" : WrapperMaxKryptStringFunc (copyCurrentEntry ),
92
92
"use-db" : setActiveDatabasePath ,
93
93
"export" : exportToFile ,
94
94
}
95
95
96
+ stringListActionsMap := map [string ]actionFunc {
97
+ "find" : WrapperMaxKryptStringFunc (findCurrentEntry ),
98
+ }
99
+
96
100
stringActions2Map := map [string ]actionFunc2 {
97
101
"decrypt" : decryptDatabase ,
98
102
}
@@ -146,6 +150,18 @@ func performAction(optMap map[string]interface{}) {
146
150
}
147
151
}
148
152
153
+ for key , mappedFunc := range stringListActionsMap {
154
+ if len (* optMap [key ].(* []string )) > 0 {
155
+
156
+ var vals = * (optMap [key ].(* []string ))
157
+ // Convert to single string
158
+ var singleVal = strings .Join (vals , " " )
159
+ mappedFunc (singleVal )
160
+ flag = true
161
+ break
162
+ }
163
+ }
164
+
149
165
if flag {
150
166
return
151
167
}
@@ -171,7 +187,6 @@ func initializeCmdLine(parser *argparse.Parser) map[string]interface{} {
171
187
{"C" , "clone" , "Clone an entry with <id>" , "<id>" , "" },
172
188
{"R" , "remove" , "Remove an entry with <id> or <id-range>" , "<id>" , "" },
173
189
{"U" , "use-db" , "Set <path> as active database" , "<path>" , "" },
174
- {"f" , "find" , "Search entries with <term>" , "<term>" , "" },
175
190
{"E" , "edit" , "Edit entry by <id>" , "<id>" , "" },
176
191
{"l" , "list-entry" , "List entry by <id>" , "<id>" , "" },
177
192
{"x" , "export" , "Export all entries to <filename>" , "<filename>" , "" },
@@ -181,6 +196,14 @@ func initializeCmdLine(parser *argparse.Parser) map[string]interface{} {
181
196
optMap [opt .Long ] = parser .String (opt .Short , opt .Long , & argparse.Options {Help : opt .Help , Path : opt .Path })
182
197
}
183
198
199
+ stringListOptions := []CmdOption {
200
+ {"f" , "find" , "Search entries with terms" , "<t1> <t2> ..." , "" },
201
+ }
202
+
203
+ for _ , opt := range stringListOptions {
204
+ optMap [opt .Long ] = parser .StringList (opt .Short , opt .Long , & argparse.Options {Help : opt .Help , Path : opt .Path })
205
+ }
206
+
184
207
boolOptions := []CmdOption {
185
208
{"e" , "encrypt" , "Encrypt the current database" , "" , "" },
186
209
{"A" , "add" , "Add a new entry" , "" , "" },
0 commit comments