File tree 1 file changed +10
-2
lines changed
1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 7
7
"io/ioutil"
8
8
"log"
9
9
"os"
10
+ "regexp"
10
11
"strings"
11
12
12
13
"jsonfind/pkg/scout"
@@ -23,7 +24,7 @@ func main() {
23
24
Name : "jf" ,
24
25
Usage : "JSONFind" ,
25
26
UsageText : "jf <valueToFind> <jsonFile>" ,
26
- Version : "1.1.0 " ,
27
+ Version : "1.1.1 " ,
27
28
Description : "Search a JSON file for a specified value and output full paths of each occurrence found" ,
28
29
Action : entrypoint ,
29
30
Flags : []cli.Flag {
@@ -64,7 +65,14 @@ func entrypoint(c *cli.Context) error {
64
65
return fmt .Errorf ("%v\n jf was unable to parse the JSON file" , err )
65
66
}
66
67
67
- scout := scout .New (lookingFor , result , c .Bool (flagUseRegex ))
68
+ useRegex := c .Bool (flagUseRegex )
69
+ if useRegex {
70
+ if _ , err := regexp .Compile (lookingFor ); err != nil {
71
+ return fmt .Errorf ("regex search term is invalid: %v" , lookingFor )
72
+ }
73
+ }
74
+
75
+ scout := scout .New (lookingFor , result , useRegex )
68
76
found , err := scout .DoSearch ()
69
77
if err != nil {
70
78
return err
You can’t perform that action at this time.
0 commit comments