Commit 56e28a3f authored by Herbert Valerio Riedel's avatar Herbert Valerio Riedel 🕺

GHCi: Implement new `:show paths` sub-command

`:show paths` dumps the current working directory as well
as the current value of the `importPaths` dynamic flags field.

This addresses #8172
Signed-off-by: Herbert Valerio Riedel's avatarHerbert Valerio Riedel <hvr@gnu.org>
parent ef017944
......@@ -315,6 +315,7 @@ defFullHelpText =
" :show linker show current linker state\n" ++
" :show modules show the currently loaded modules\n" ++
" :show packages show the currently active package flags\n" ++
" :show paths show the currently active search paths\n" ++
" :show language show the currently active language flags\n" ++
" :show <setting> show value of <setting>, which is one of\n" ++
" [args, prog, prompt, editor, stop]\n" ++
......@@ -2156,6 +2157,7 @@ showCmd str = do
["breaks"] -> showBkptTable
["context"] -> showContext
["packages"] -> showPackages
["paths"] -> showPaths
["languages"] -> showLanguages -- backwards compat
["language"] -> showLanguages
["lang"] -> showLanguages -- useful abbreviation
......@@ -2263,6 +2265,19 @@ showPackages = do
showFlag (TrustPackage p) = text $ " -trust " ++ p
showFlag (DistrustPackage p) = text $ " -distrust " ++ p
showPaths :: GHCi ()
showPaths = do
dflags <- getDynFlags
liftIO $ do
cwd <- getCurrentDirectory
putStrLn $ showSDoc dflags $
text "current working directory: " $$
nest 2 (text cwd)
let ipaths = importPaths dflags
putStrLn $ showSDoc dflags $
text ("module import search paths:"++if null ipaths then " none" else "") $$
nest 2 (vcat (map text ipaths))
showLanguages :: GHCi ()
showLanguages = getDynFlags >>= liftIO . showLanguages' False
......@@ -2423,7 +2438,7 @@ completeShowOptions = wrapCompleter flagWordBreakChars $ \w -> do
return (filter (w `isPrefixOf`) opts)
where opts = ["args", "prog", "prompt", "prompt2", "editor", "stop",
"modules", "bindings", "linker", "breaks",
"context", "packages", "language", "imports"]
"context", "packages", "paths", "language", "imports"]
completeShowiOptions = wrapCompleter flagWordBreakChars $ \w -> do
return (filter (w `isPrefixOf`) ["language"])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment