43
43
data Command
44
44
= Initialize JengaConfig
45
45
| Update
46
- | Parse StackFilePath
46
+ | ParseStack StackFilePath
47
+ | ParseJenga FilePath
47
48
48
49
49
50
pCommand :: Parser Command
@@ -62,10 +63,14 @@ pCommand = O.subparser $ mconcat
62
63
<> " or other things) and want to build is the new updated project. This sub command"
63
64
<> " expects a '.jenga' file in the same directory as the 'stack.yaml' file." )
64
65
(pure Update )
65
- , subCommand " parse"
66
- ( " Parse the 'stack.yaml' file and dump out the relevant bits as JSON. This is "
66
+ , subCommand " parse-stack "
67
+ ( " Parse a 'stack.yaml' file and dump out the relevant bits as JSON. This is "
67
68
<> " mostly useful for testing and debugging." )
68
- (Parse <$> stackFilePathP)
69
+ (ParseStack <$> stackFilePathP)
70
+ , subCommand " parse-jenga"
71
+ ( " Parse the '.jenga' file and dump out the relevant bits as JSON. This is "
72
+ <> " mostly useful for testing and debugging." )
73
+ (ParseJenga <$> jengaFilePathP)
69
74
]
70
75
where
71
76
subCommand :: String -> Doc -> Parser a -> Mod CommandFields a
@@ -110,6 +115,15 @@ stackFilePathP =
110
115
<> help " The 'stack.yaml' file. (defaults to './stack.yaml')."
111
116
)
112
117
118
+ jengaFilePathP :: Parser FilePath
119
+ jengaFilePathP =
120
+ fmap (fromMaybe " .jenga" ) <$> O. optional $ strOption
121
+ ( short ' j'
122
+ <> long " jenga-file"
123
+ <> metavar " JENGA_FILE"
124
+ <> help " The '.jenga' file. (defaults to './.jenga')."
125
+ )
126
+
113
127
-- -----------------------------------------------------------------------------
114
128
115
129
commandHandler :: Command -> IO ()
@@ -118,7 +132,8 @@ commandHandler cmd =
118
132
case cmd of
119
133
Initialize cfg -> initialize cfg
120
134
Update -> update
121
- Parse scfg -> dumpStackToJSON scfg
135
+ ParseStack scfg -> dumpStackToJSON scfg
136
+ ParseJenga jcfg -> dumpJengaToJSON jcfg
122
137
123
138
initialize :: JengaConfig -> EitherT JengaError IO ()
124
139
initialize jcfg = do
@@ -165,6 +180,11 @@ dumpStackToJSON stackFile = do
165
180
scfg <- readStackConfig stackFile
166
181
liftIO . BS. putStrLn $ renderStackConfig scfg
167
182
183
+ dumpJengaToJSON :: FilePath -> EitherT JengaError IO ()
184
+ dumpJengaToJSON file = do
185
+ jcfg <- readJengaConfigFrom file
186
+ liftIO . BS. putStrLn $ renderJengaConfig jcfg
187
+
168
188
-- -----------------------------------------------------------------------------
169
189
170
190
checkModulesDirPath :: ModulesDirPath -> EitherT JengaError IO ()
0 commit comments