@@ -155,20 +155,8 @@ parseRawTargetDirs root locals ri =
155
155
>>= rejectMissingDir
156
156
case mdir of
157
157
Nothing -> pure . Left $
158
- if | T. isPrefixOf " stack-yaml" t ->
159
- fillSep
160
- [ flow " Directory not found:"
161
- , style Dir (fromString $ T. unpack t) <> " ."
162
- , flow " Is this a typo? Can I suggest:"
163
- , style Dir (fromString $ " --" ++ T. unpack t)
164
- ]
165
- | T. isSuffixOf " .yaml" t ->
166
- fillSep
167
- [ flow " Directory not found:"
168
- , style Dir (fromString $ T. unpack t) <> " ."
169
- , flow " Is this a typo? Can I suggest:"
170
- , style Dir (fromString $ " --stack-yaml " ++ T. unpack t)
171
- ]
158
+ if | T. isPrefixOf " stack-yaml=" t -> projectOptionTypo
159
+ | T. isSuffixOf " .yaml" t -> projectYamlExtTypo
172
160
| otherwise ->
173
161
fillSep
174
162
[ flow " Directory not found:"
@@ -191,6 +179,22 @@ parseRawTargetDirs root locals ri =
191
179
192
180
RawInput t = ri
193
181
182
+ projectOptionTypo :: StyleDoc
183
+ projectOptionTypo = let o = " stack-yaml=" in projectTypo 2 (length o) o
184
+
185
+ projectYamlExtTypo :: StyleDoc
186
+ projectYamlExtTypo = let o = " stack-yaml " in projectTypo (2 + length o) 0 o
187
+
188
+ projectTypo :: Int -> Int -> String -> StyleDoc
189
+ projectTypo padLength dropLength option =
190
+ vsep
191
+ [ style Dir ((fromString $ replicate padLength ' ' ) <> (fromString $ T. unpack t))
192
+ <> " is not a directory."
193
+ , style Highlight (fromString $ " --" <> option)
194
+ <> style Dir (fromString . drop dropLength $ T. unpack t)
195
+ <> " might work as a project option."
196
+ ]
197
+
194
198
-- | If this function returns @Nothing@, the input should be treated as a
195
199
-- directory.
196
200
parseRawTarget :: Text -> Maybe RawTarget
0 commit comments