on master help sign in
Merge pull request #3347 from jfdm/show-info-flag

Addition of new flag `--info` and other improvements.

commit37fdae09714127d597bb23a0625399ed904a3865 authorJan de Muijnck-Hughes <jfdm@users.noreply.github.com> dateMon 8 Aug 2016, 11:32 (10 years ago) parentc8e4651cb210b1
8 files changed+118−31
CHANGELOG.md+1 idris.cabal+1 main/Main.hs+8−30 src/Idris/AbsSyntaxTree.hs+1 src/Idris/CmdOptions.hs+1 src/Idris/Info.hs+11 src/Idris/Info/Show.hs+95 src/Idris/REPL.hs−1
CHANGELOG.md+1
@@ -33,6 +33,7 @@
3333* Idris' documentation system now displays the documentation for auto
3434 implicits in the output of `:doc`. This is tested for in `docs005`.
3535
36+* New command line flag `--info` that displays information about the installation.
3637## Miscellaneous updates
3738
3839* The test suite now uses [tasty-golden](https://hackage.haskell.org/package/tasty-golden). New tests must be registered in `test/TestData.hs`, as explained in the relevant `README.md`.
idris.cabal+1
@@ -189,6 +189,7 @@ Library
189189 , Idris.IdrisDoc
190190 , Idris.Imports
191191 , Idris.Info
192+ , Idris.Info.Show
192193 , Idris.Inliner
193194 , Idris.Interactive
194195 , Idris.Output
main/Main.hs+8−30
@@ -6,10 +6,11 @@ import Control.Monad ( when )
66
77import Idris.AbsSyntax
88import Idris.REPL
9−import Idris.Imports
9+-- import Idris.Imports
1010import Idris.Error
1111import Idris.CmdOptions
1212import Idris.Info
13+import Idris.Info.Show
1314import Idris.Package
1415
1516
@@ -28,11 +29,12 @@ main = do opts <- runArgParser
2829runIdris :: [Opt] -> Idris ()
2930runIdris opts = do
3031 runIO setupBundledCC
31− when (ShowLoggingCats `elem` opts) $ runIO showLoggingCats
32− when (ShowIncs `elem` opts) $ runIO showIncs
33− when (ShowLibs `elem` opts) $ runIO showLibs
34− when (ShowLibdir `elem` opts) $ runIO showLibdir
35− when (ShowPkgs `elem` opts) $ runIO showPkgs
32+ when (ShowAll `elem` opts) $ runIO showExitIdrisInfo
33+ when (ShowLoggingCats `elem` opts) $ runIO showExitIdrisLoggingCategories
34+ when (ShowIncs `elem` opts) $ runIO showExitIdrisFlagsInc
35+ when (ShowLibs `elem` opts) $ runIO showExitIdrisFlagsLibs
36+ when (ShowLibdir `elem` opts) $ runIO showExitIdrisLibDir
37+ when (ShowPkgs `elem` opts) $ runIO showExitIdrisInstalledPackages
3638 case opt getClient opts of
3739 [] -> return ()
3840 (c:_) -> do setVerbose False
@@ -61,27 +63,3 @@ runIdris opts = do
6163 [f] -> replPkg opts f
6264 _ -> ifail "Too many packages"
6365 fs -> runIO $ mapM_ (buildPkg opts (WarnOnly `elem` opts)) fs
64−
65−showLibs :: IO b
66−showLibs = do libFlags <- getIdrisFlagsLib
67− putStrLn $ unwords libFlags
68− exitSuccess
69−
70−showLibdir :: IO b
71−showLibdir = do putStrLn =<< getIdrisLibDir
72− exitSuccess
73−
74−showIncs :: IO b
75−showIncs = do incFlags <- getIdrisFlagsInc
76− putStrLn $ unwords incFlags
77− exitSuccess
78−
79−-- | List idris packages installed
80−showPkgs :: IO b
81−showPkgs = do mapM_ putStrLn =<< installedPackages
82− exitSuccess
83−
84−showLoggingCats :: IO b
85−showLoggingCats = do
86− putStrLn loggingCatsStr
87− exitSuccess
src/Idris/AbsSyntaxTree.hs+1
@@ -550,6 +550,7 @@ data Opt = Filename String
550550 | ColourREPL Bool
551551 | Idemode
552552 | IdemodeSocket
553+ | ShowAll
553554 | ShowLibs
554555 | ShowLibdir
555556 | ShowIncs
src/Idris/CmdOptions.hs+1
@@ -114,6 +114,7 @@ parseFlags = many $
114114 <|> flag' ErrContext (long "errorcontext")
115115
116116 -- Show things
117+ <|> flag' ShowAll (long "info" <> help "Display information about installation.")
117118 <|> flag' ShowLoggingCats (long "listlogcats" <> help "Display logging categories")
118119 <|> flag' ShowLibs (long "link" <> help "Display link flags")
119120 <|> flag' ShowPkgs (long "listlibs" <> help "Display installed libraries")
src/Idris/Info.hs+11
@@ -16,12 +16,17 @@ module Idris.Info
1616 , getIdrisUserDataDir
1717 , getIdrisInitScript
1818 , getIdrisHistoryFile
19+ , getIdrisInstalledPackages
20+ , getIdrisLoggingCategories
1921 ) where
2022
2123import System.FilePath
2224import System.Directory
2325import Data.Version
2426
27+import Idris.Imports (installedPackages)
28+import Idris.AbsSyntax (loggingCatsStr)
29+
2530import qualified IRTS.System as S
2631
2732import Version_idris (gitHash)
@@ -64,3 +69,9 @@ getIdrisHistoryFile :: IO FilePath
6469getIdrisHistoryFile = do
6570 udir <- getIdrisUserDataDir
6671 return (udir </> "repl" </> "history")
72+
73+getIdrisInstalledPackages :: IO [String]
74+getIdrisInstalledPackages = installedPackages
75+
76+getIdrisLoggingCategories :: IO [String]
77+getIdrisLoggingCategories = return $ words loggingCatsStr
src/Idris/Info/Show.hsnew file+95
@@ -0,0 +1,95 @@
1+module Idris.Info.Show where
2+
3+import System.Exit
4+
5+import Idris.Info
6+
7+showIdrisFlagsLibs :: IO ()
8+showIdrisFlagsLibs = do
9+ libFlags <- getIdrisFlagsLib
10+ putStrLn $ unwords libFlags
11+
12+showExitIdrisFlagsLibs :: IO ()
13+showExitIdrisFlagsLibs = do
14+ showIdrisFlagsLibs
15+ exitSuccess
16+
17+showIdrisLibDir :: IO ()
18+showIdrisLibDir = do
19+ ldir <- getIdrisLibDir
20+ putStrLn ldir
21+
22+showExitIdrisLibDir :: IO ()
23+showExitIdrisLibDir = do
24+ showIdrisLibDir
25+ exitSuccess
26+
27+showIdrisFlagsInc :: IO ()
28+showIdrisFlagsInc = do
29+ incFlags <- getIdrisFlagsInc
30+ putStrLn $ unwords incFlags
31+
32+showExitIdrisFlagsInc :: IO ()
33+showExitIdrisFlagsInc = do
34+ showIdrisFlagsInc
35+ exitSuccess
36+
37+-- | List idris packages installed
38+showIdrisInstalledPackages :: IO ()
39+showIdrisInstalledPackages = do
40+ ipkgs <- getIdrisInstalledPackages
41+ mapM_ putStrLn ipkgs
42+
43+showExitIdrisInstalledPackages :: IO ()
44+showExitIdrisInstalledPackages = do
45+ showIdrisInstalledPackages
46+ exitSuccess
47+
48+showIdrisLoggingCategories :: IO ()
49+showIdrisLoggingCategories = do
50+ cs <- getIdrisLoggingCategories
51+ mapM_ putStrLn cs
52+
53+showExitIdrisLoggingCategories :: IO ()
54+showExitIdrisLoggingCategories = do
55+ showIdrisLoggingCategories
56+ exitSuccess
57+
58+showIdrisInfo :: IO ()
59+showIdrisInfo = do
60+ putStrLn $ unwords ["Idris", getIdrisVersion]
61+
62+ ps <- getIdrisInstalledPackages
63+ putStrLn $ unwords (["Installed Packages:"] ++ ps)
64+
65+ cs <- getIdrisLoggingCategories
66+ putStrLn $ unwords (["Logging Categories:"] ++ cs)
67+
68+ putStrLn "Paths:"
69+ ldir <- getIdrisLibDir
70+ udir <- getIdrisUserDataDir
71+ putStrLn $ unwords ["-", "Library Dir:", ldir]
72+ putStrLn $ unwords ["-", "User Dir:", udir]
73+
74+ putStrLn "Flags:"
75+ lflag <- getIdrisFlagsLib
76+ iflag <- getIdrisFlagsInc
77+ eflag <- getIdrisFlagsEnv
78+ putStrLn $ unwords (["-", "Libraries:", show lflag])
79+ putStrLn $ unwords (["-", "Includes:", show iflag])
80+ putStrLn $ unwords (["-", "Env:", show eflag])
81+
82+ cc <- getIdrisCC
83+ putStrLn $ unwords ["CC:", cc]
84+
85+ putStrLn "Files:"
86+ hfile <- getIdrisHistoryFile
87+ iscript <- getIdrisInitScript
88+ putStrLn $ unwords (["-", "History File:", hfile])
89+ putStrLn $ unwords (["-", "REPL Init Script", iscript])
90+
91+
92+showExitIdrisInfo :: IO ()
93+showExitIdrisInfo = do
94+ showIdrisInfo
95+ exitSuccess
src/Idris/REPL.hs−1
@@ -73,7 +73,6 @@ import Idris.Core.Constraints
7373import IRTS.Compiler
7474import IRTS.CodegenCommon
7575import IRTS.Exports
76−--import IRTS.System
7776
7877import Control.Category
7978import qualified Control.Exception as X