1
1
{-# LANGUAGE NoImplicitPrelude #-}
2
2
{-# LANGUAGE DataKinds #-}
3
3
{-# LANGUAGE GADTs #-}
4
+ {-# LANGUAGE MultiWayIf #-}
4
5
{-# LANGUAGE OverloadedStrings #-}
5
6
{-# LANGUAGE ViewPatterns #-}
6
7
@@ -152,11 +153,14 @@ parseRawTargetDirs root locals ri =
152
153
Nothing -> do
153
154
mdir <- forgivingResolveDir root (T. unpack t) >>= rejectMissingDir
154
155
case mdir of
155
- Nothing -> pure $ Left $
156
- fillSep
157
- [ flow " Directory not found:"
158
- , style Dir (fromString $ T. unpack t) <> " ."
159
- ]
156
+ Nothing -> pure . Left $
157
+ if | T. isPrefixOf " stack-yaml=" t -> projectOptionTypo
158
+ | T. isSuffixOf " .yaml" t -> projectYamlExtTypo
159
+ | otherwise ->
160
+ fillSep
161
+ [ flow " Directory not found:"
162
+ , style Dir (fromString $ T. unpack t) <> " ."
163
+ ]
160
164
Just dir ->
161
165
case mapMaybe (childOf dir) $ Map. toList locals of
162
166
[] -> pure $ Left $
@@ -174,6 +178,22 @@ parseRawTargetDirs root locals ri =
174
178
175
179
RawInput t = ri
176
180
181
+ projectOptionTypo :: StyleDoc
182
+ projectOptionTypo = let o = " stack-yaml=" in projectTypo 2 (length o) o
183
+
184
+ projectYamlExtTypo :: StyleDoc
185
+ projectYamlExtTypo = let o = " stack-yaml " in projectTypo (2 + length o) 0 o
186
+
187
+ projectTypo :: Int -> Int -> String -> StyleDoc
188
+ projectTypo padLength dropLength option =
189
+ vsep
190
+ [ style Dir (fromString (replicate padLength ' ' ) <> fromString (T. unpack t))
191
+ <> " is not a directory."
192
+ , style Highlight (fromString $ " --" <> option)
193
+ <> style Dir (fromString . drop dropLength $ T. unpack t)
194
+ <> " might work as a project option."
195
+ ]
196
+
177
197
-- | If this function returns @Nothing@, the input should be treated as a
178
198
-- directory.
179
199
parseRawTarget :: Text -> Maybe RawTarget
0 commit comments