@@ -272,13 +272,24 @@ exitWithError err =
272272 BadArgs argErrors ->
273273 case argErrors of
274274 [] ->
275− error "TODO no possible args"
275+ return
276+ [ reflow $ "I was not expecting any arguments for this command."
277+ , reflow $ "Try removing them?"
278+ ]
276279
277280 [(_args, argError)] ->
278281 argErrorToDocs argError
279282
280283 _:_:_ ->
281− error "TODO show possible arg configurations"
284+ argErrorToDocs $ head $ List.sortOn toArgErrorRank (map snd argErrors)
285+
286+
287+toArgErrorRank :: ArgError -> Int -- lower is better
288+toArgErrorRank err =
289+ case err of
290+ ArgBad _ _ -> 0
291+ ArgMissing _ -> 1
292+ ArgExtras _ -> 2
282293
283294
284295toGreen :: String -> P.Doc
@@ -318,10 +329,10 @@ argErrorToDocs argError =
318329 return
319330 [ "I am having trouble with this argument:"
320331 , P.indent 4 $ toRed string
321− , P.fillSep
332+ , P.fillSep $
322333 ["It","is","supposed","to","be","a"
323− ,toYellow (toToken tipe),"value,","like","this:"
324− ]
334+ ,toYellow (toToken tipe),"value,","like"
335+ ] ++ if length examples == 1 then ["this:"] else ["one","of","these:"]
325336 , P.indent 4 $ P.green $ P.vcat $ map P.text examples
326337 ]
327338