Ticket #7130: 0001-Give-suggestions-for-unrecognised-command-line-argum.patch

File 0001-Give-suggestions-for-unrecognised-command-line-argum.patch, 897 bytes (added by nomeata, 2 years ago)
  • ghc/Main.hs

    From 88c83b065a59ecd4cd6626e0f9d71d44c5d3b881 Mon Sep 17 00:00:00 2001
    From: Joachim Breitner <mail@joachim-breitner.de>
    Date: Thu, 9 Aug 2012 16:10:56 +0200
    Subject: [PATCH] Give suggestions for unrecognised command line arguments
    
    ---
     ghc/Main.hs |    9 +++++++--
     1 file changed, 7 insertions(+), 2 deletions(-)
    
    diff --git a/ghc/Main.hs b/ghc/Main.hs
    index 1e9d0a2..5eda655 100644
    a b abiHash strs = do 
    791791-- Util 
    792792 
    793793unknownFlagsErr :: [String] -> a 
    794 unknownFlagsErr fs = ghcError (UsageError ("unrecognised flags: " ++ unwords fs)) 
    795  
     794unknownFlagsErr fs = ghcError $ UsageError $ concatMap oneError fs 
     795  where 
     796    oneError f = 
     797        "unrecognised flag: " ++ f ++ "\n" ++ 
     798        (case fuzzyMatch f (nub allFlags) of 
     799            [] -> "" 
     800            suggs -> "did you mean one of:\n" ++ unlines (map ("  " ++) suggs))