on master help sign in
Addition of a command line flag `--info`.

New command line flag `--info` that displays information about the installation.

commitcb210b16faa66550984d74aeaf03f4b66726126f authorJan de Muijnck-Hughes <jfdm@st-andrews.ac.uk> dateSun 7 Aug 2016, 21:01 (10 years ago) parente9faa69
6 files changed+44−1
CHANGELOG.md+1 main/Main.hs+1 src/Idris/AbsSyntaxTree.hs+1 src/Idris/CmdOptions.hs+1 src/Idris/Info.hs+1−1 src/Idris/Info/Show.hs+39
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`.
main/Main.hs+1
@@ -29,6 +29,7 @@ main = do opts <- runArgParser
2929runIdris :: [Opt] -> Idris ()
3030runIdris opts = do
3131 runIO setupBundledCC
32+ when (ShowAll `elem` opts) $ runIO showExitIdrisInfo
3233 when (ShowLoggingCats `elem` opts) $ runIO showExitIdrisLoggingCategories
3334 when (ShowIncs `elem` opts) $ runIO showExitIdrisFlagsInc
3435 when (ShowLibs `elem` opts) $ runIO showExitIdrisFlagsLibs
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+1−1
@@ -74,4 +74,4 @@ getIdrisInstalledPackages :: IO [String]
7474getIdrisInstalledPackages = installedPackages
7575
7676getIdrisLoggingCategories :: IO [String]
77−getIdrisLoggingCategories = pure $ words loggingCatsStr
77+getIdrisLoggingCategories = return $ words loggingCatsStr
src/Idris/Info/Show.hs+39
@@ -54,3 +54,42 @@ showExitIdrisLoggingCategories :: IO ()
5454showExitIdrisLoggingCategories = do
5555 showIdrisLoggingCategories
5656 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