[commit: ghc] master: Give suggestions for unrecognised command line arguments (82373c7)
Paolo Capriotti
p.capriotti at gmail.com
Mon Aug 13 20:36:51 CEST 2012
Repository : ssh://darcs.haskell.org//srv/darcs/ghc
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/82373c76fb895d6f713b19f0c58b17f2d6ef35c4
>---------------------------------------------------------------
commit 82373c76fb895d6f713b19f0c58b17f2d6ef35c4
Author: Joachim Breitner <mail at joachim-breitner.de>
Date: Thu Aug 9 16:10:56 2012 +0200
Give suggestions for unrecognised command line arguments
>---------------------------------------------------------------
ghc/Main.hs | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/ghc/Main.hs b/ghc/Main.hs
index 1e9d0a2..5eda655 100644
--- a/ghc/Main.hs
+++ b/ghc/Main.hs
@@ -791,5 +791,10 @@ abiHash strs = do
-- Util
unknownFlagsErr :: [String] -> a
-unknownFlagsErr fs = ghcError (UsageError ("unrecognised flags: " ++ unwords fs))
-
+unknownFlagsErr fs = ghcError $ UsageError $ concatMap oneError fs
+ where
+ oneError f =
+ "unrecognised flag: " ++ f ++ "\n" ++
+ (case fuzzyMatch f (nub allFlags) of
+ [] -> ""
+ suggs -> "did you mean one of:\n" ++ unlines (map (" " ++) suggs))
More information about the Cvs-ghc
mailing list