File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import "language-powerquery" Language.PowerQuery
14
14
data Lex
15
15
= Lex
16
16
{ _lex_path :: ! (Maybe FilePath )
17
+ , _lex_json :: ! Bool
17
18
}
18
19
19
20
data Parse
@@ -40,6 +41,11 @@ lexParser = C1 <$> (Lex
40
41
<> metavar " PATH"
41
42
<> help " Lex PowerQuery Text"
42
43
))
44
+ <*> switch
45
+ ( long " json"
46
+ <> short ' j'
47
+ <> help " print Tokens as JSON"
48
+ )
43
49
)
44
50
45
51
parseParser :: Parser Command
@@ -73,12 +79,14 @@ readPathOrStdin (Just path) = B.readFile path
73
79
74
80
75
81
lex :: Lex -> IO ()
76
- lex (Lex mPath) = do
82
+ lex (Lex mPath shouldJSON ) = do
77
83
bs <- readPathOrStdin mPath
78
84
let tokens = lexer
79
85
. B. unpack
80
86
$ bs
81
- print tokens
87
+ if shouldJSON
88
+ then B. putStrLn . encode $ tokens
89
+ else print $ tokens
82
90
return ()
83
91
84
92
You can’t perform that action at this time.
0 commit comments