From 043500e8e80d14a317a252b112144eaaf3efb15f Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sat, 12 Nov 2022 20:19:17 +0800 Subject: [PATCH] Optimize 'ghcup whereis ghcup' --- app/ghcup/GHCup/OptParse/Whereis.hs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/ghcup/GHCup/OptParse/Whereis.hs b/app/ghcup/GHCup/OptParse/Whereis.hs index 152021c..4df064f 100644 --- a/app/ghcup/GHCup/OptParse/Whereis.hs +++ b/app/ghcup/GHCup/OptParse/Whereis.hs @@ -32,6 +32,7 @@ import Haskus.Utils.Variant.Excepts import Options.Applicative hiding ( style ) import Options.Applicative.Help.Pretty ( text ) import Prelude hiding ( appendFile ) +import System.Environment import System.Exit import Text.PrettyPrint.HughesPJClass ( prettyShow ) @@ -268,6 +269,13 @@ whereis :: ( Monad m whereis whereisCommand whereisOptions runAppState leanAppstate runLogger = do Dirs{ .. } <- runReaderT getDirs leanAppstate case (whereisCommand, whereisOptions) of + (WhereisTool GHCup _, WhereisOptions{..}) -> do + loc <- liftIO (getExecutablePath >>= canonicalizePath ) + if directory + then liftIO $ putStr $ takeDirectory loc + else liftIO $ putStr loc + pure ExitSuccess + (WhereisTool tool (Just (GHCVersion v)), WhereisOptions{..}) -> runLeanWhereIs leanAppstate (do loc <- liftE $ whereIsTool tool v