Optimize 'ghcup whereis ghcup'
This commit is contained in:
parent
e924ad8278
commit
043500e8e8
@ -32,6 +32,7 @@ import Haskus.Utils.Variant.Excepts
|
|||||||
import Options.Applicative hiding ( style )
|
import Options.Applicative hiding ( style )
|
||||||
import Options.Applicative.Help.Pretty ( text )
|
import Options.Applicative.Help.Pretty ( text )
|
||||||
import Prelude hiding ( appendFile )
|
import Prelude hiding ( appendFile )
|
||||||
|
import System.Environment
|
||||||
import System.Exit
|
import System.Exit
|
||||||
import Text.PrettyPrint.HughesPJClass ( prettyShow )
|
import Text.PrettyPrint.HughesPJClass ( prettyShow )
|
||||||
|
|
||||||
@ -268,6 +269,13 @@ whereis :: ( Monad m
|
|||||||
whereis whereisCommand whereisOptions runAppState leanAppstate runLogger = do
|
whereis whereisCommand whereisOptions runAppState leanAppstate runLogger = do
|
||||||
Dirs{ .. } <- runReaderT getDirs leanAppstate
|
Dirs{ .. } <- runReaderT getDirs leanAppstate
|
||||||
case (whereisCommand, whereisOptions) of
|
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{..}) ->
|
(WhereisTool tool (Just (GHCVersion v)), WhereisOptions{..}) ->
|
||||||
runLeanWhereIs leanAppstate (do
|
runLeanWhereIs leanAppstate (do
|
||||||
loc <- liftE $ whereIsTool tool v
|
loc <- liftE $ whereIsTool tool v
|
||||||
|
Loading…
Reference in New Issue
Block a user