@@ -259,8 +259,8 @@ exitWithUnknown unknown knowns =
259259-- ERROR TO DOC
260260
261261
262−exitWithError :: Maybe String -> Error -> IO a
263−exitWithError maybeCommand err =
262+exitWithError :: Error -> IO a
263+exitWithError err =
264264 exitFailure =<<
265265 case err of
266266 BadFlag flagError ->
@@ -271,8 +271,8 @@ exitWithError maybeCommand err =
271271 [] ->
272272 error "TODO no possible args"
273273
274− [(args, argError)] ->
275− argErrorToDocs maybeCommand args argError
274+ [(_args, argError)] ->
275+ argErrorToDocs argError
276276
277277 _:_:_ ->
278278 error "TODO show possible arg configurations"
@@ -297,54 +297,43 @@ toRed str =
297297-- ARG ERROR TO DOC
298298
299299
300−argErrorHelp :: Maybe String -> CompleteArgs a -> [P.Doc] -> IO [P.Doc]
301−argErrorHelp maybeCommand args details =
302− do command <- toCommand maybeCommand
303− return $
304− [ "I was expecting arguments like this:"
305− , P.indent 4 $ P.dullcyan $ argsToDoc command args
306− ]
307− ++ details
308−
309−
310−argErrorToDocs :: Maybe String -> CompleteArgs a -> ArgError -> IO [P.Doc]
311−argErrorToDocs maybeCommand args argError =
312− argErrorHelp maybeCommand args =<<
313− case argError of
314− ArgMissing (Expectation tipe makeExamples) ->
315− do examples <- makeExamples
316− return
317− [ P.fillSep
318− ["Everything","you","have","is","fine,","but","in","addition,","I","was"
319− ,"expecting","a",toYellow (toToken tipe),"value.","For","example:"
320− ]
321− , P.indent 4 $ P.green $ P.vcat $ map P.text examples
322− ]
300+argErrorToDocs :: ArgError -> IO [P.Doc]
301+argErrorToDocs argError =
302+ case argError of
303+ ArgMissing (Expectation tipe makeExamples) ->
304+ do examples <- makeExamples
305+ return
306+ [ P.fillSep
307+ ["The","arguments","you","have","are","fine,","but","in","addition,","I","was"
308+ ,"expecting","a",toYellow (toToken tipe),"value.","For","example:"
309+ ]
310+ , P.indent 4 $ P.green $ P.vcat $ map P.text examples
311+ ]
323312
324− ArgBad string (Expectation tipe makeExamples) ->
325− do examples <- makeExamples
326− return
327− [ "I am having trouble with this argument though:"
328− , P.indent 4 $ toRed string
329− , P.fillSep
330− ["It","is","supposed","to","be","a"
331− ,toYellow (toToken tipe),"value,","like","this:"
332− ]
333− , P.indent 4 $ P.green $ P.vcat $ map P.text examples
334− ]
313+ ArgBad string (Expectation tipe makeExamples) ->
314+ do examples <- makeExamples
315+ return
316+ [ "I am having trouble with this argument:"
317+ , P.indent 4 $ toRed string
318+ , P.fillSep
319+ ["It","is","supposed","to","be","a"
320+ ,toYellow (toToken tipe),"value,","like","this:"
321+ ]
322+ , P.indent 4 $ P.green $ P.vcat $ map P.text examples
323+ ]
335324
336− ArgExtras extras ->
337− let
338− (these, them) =
339− case extras of
340− [_] -> ("this extra argument", "it")
341− _ -> ("these extra arguments", "them")
342− in
343− return
344− [ reflow $ "That worked, but I did not know what to do with " ++ these ++ ":"
345− , P.indent 4 $ P.red $ P.vcat $ map P.text extras
346− , reflow $ "Try removing " ++ them ++ "?"
347− ]
325+ ArgExtras extras ->
326+ let
327+ (these, them) =
328+ case extras of
329+ [_] -> ("this argument", "it")
330+ _ -> ("these arguments", "them")
331+ in
332+ return
333+ [ reflow $ "I was not expecting " ++ these ++ ":"
334+ , P.indent 4 $ P.red $ P.vcat $ map P.text extras
335+ , reflow $ "Try removing " ++ them ++ "?"
336+ ]
348337
349338
350339