on master help sign in
Merge pull request #2869 from jfdm/list-categories

Added flag to display available logging categories.

commitd3d679eeffd23342529892ef929044a9e44aeb5e authorJan de Muijnck-Hughes <jfdm@users.noreply.github.com> dateSun 20 Dec 2015, 08:49 (11 years ago) parentb3db250fd9003b
6 files changed+47−19
CHANGELOG+1−1 main/Main.hs+6 src/Idris/AbsSyntaxTree.hs+19 src/Idris/CmdOptions.hs+14−12 src/Idris/DeepSeq.hs+1 src/Idris/REPLParser.hs+6−6
CHANGELOG+1−1
@@ -7,7 +7,7 @@ New in 0.9.21:
77 string containing the categories to log. The REPL command is `logcats CATS`.
88 Where `CATS` is a whitespace separated list of categoriese. Default is for
99 all categories to be logged.
10−
10+* New flag `--listlogcats` to list logging categories.`
1111
1212New in 0.9.20:
1313==============
main/Main.hs+6
@@ -45,6 +45,7 @@ main = do opts <- runArgParser
4545runIdris :: [Opt] -> Idris ()
4646runIdris opts = do
4747 runIO setupBundledCC
48+ when (ShowLoggingCats `elem` opts) $ runIO showLoggingCats
4849 when (ShowIncs `elem` opts) $ runIO showIncs
4950 when (ShowLibs `elem` opts) $ runIO showLibs
5051 when (ShowLibdir `elem` opts) $ runIO showLibdir
@@ -101,3 +102,8 @@ showIncs = do incFlags <- getIncFlags
101102showPkgs :: IO b
102103showPkgs = do mapM putStrLn =<< installedPackages
103104 exitWith ExitSuccess
105+
106+showLoggingCats :: IO b
107+showLoggingCats = do
108+ putStrLn loggingCatsStr
109+ exitWith ExitSuccess
src/Idris/AbsSyntaxTree.hs+19
@@ -465,6 +465,14 @@ data LogCat = IParse
465465 | IIBC
466466 deriving (Show, Eq, Ord)
467467
468+strLogCat :: LogCat -> String
469+strLogCat IParse = "parser"
470+strLogCat IElab = "elab"
471+strLogCat ICodeGen = "codegen"
472+strLogCat IErasure = "erasure"
473+strLogCat ICoverage = "coverage"
474+strLogCat IIBC = "ibc"
475+
468476codegenCats :: [LogCat]
469477codegenCats = [ICodeGen]
470478
@@ -474,6 +482,16 @@ parserCats = [IParse]
474482elabCats :: [LogCat]
475483elabCats = [IElab]
476484
485+loggingCatsStr :: String
486+loggingCatsStr = unlines
487+ [ (strLogCat IParse)
488+ , (strLogCat IElab)
489+ , (strLogCat ICodeGen)
490+ , (strLogCat IErasure)
491+ , (strLogCat ICoverage)
492+ , (strLogCat IIBC)
493+ ]
494+
477495data Opt = Filename String
478496 | Quiet
479497 | NoBanner
@@ -484,6 +502,7 @@ data Opt = Filename String
484502 | ShowLibdir
485503 | ShowIncs
486504 | ShowPkgs
505+ | ShowLoggingCats
487506 | NoBasePkgs
488507 | NoPrelude
489508 | NoBuiltins -- only for the really primitive stuff!
src/Idris/CmdOptions.hs+14−12
@@ -89,7 +89,7 @@ parseFlags = many $
8989 <|> (OLogCats <$> option (str >>= parseLogCats)
9090 (long "logging-categories"
9191 <> metavar "CATS"
92− <> help "Colon separated logging categories: parser, elab, codegen, coverage, erasure"))
92+ <> help "Colon separated logging categories. Use --listlogcats to see list."))
9393
9494 -- Turn off Certain libraries.
9595 <|> flag' NoBasePkgs (long "nobasepkgs" <> help "Do not use the given base package")
@@ -106,11 +106,13 @@ parseFlags = many $
106106 <|> flag' WarnReach (long "warnreach" <> help "Warn about reachable but inaccessible arguments")
107107 <|> flag' NoCoverage (long "nocoverage")
108108 <|> flag' ErrContext (long "errorcontext")
109− <|> flag' ShowLibs (long "link" <> help "Display link flags")
110− <|> flag' ShowPkgs (long "listlibs" <> help "Display installed libraries")
111− <|> flag' ShowLibdir (long "libdir" <> help "Display library directory")
112− <|> flag' ShowIncs (long "include" <> help "Display the includes flags")
113− <|> flag' Verbose (short 'V' <> long "verbose" <> help "Loud verbosity")
109+ -- Show things
110+ <|> flag' ShowLoggingCats (long "listlogcats" <> help "Display logging categories")
111+ <|> flag' ShowLibs (long "link" <> help "Display link flags")
112+ <|> flag' ShowPkgs (long "listlibs" <> help "Display installed libraries")
113+ <|> flag' ShowLibdir (long "libdir" <> help "Display library directory")
114+ <|> flag' ShowIncs (long "include" <> help "Display the includes flags")
115+ <|> flag' Verbose (short 'V' <> long "verbose" <> help "Loud verbosity")
114116 <|> (IBCSubDir <$> strOption (long "ibcsubdir" <> metavar "FILE" <> help "Write IBC files into sub directory"))
115117 <|> (ImportDir <$> strOption (short 'i' <> long "idrispath" <> help "Add directory to the list of import paths"))
116118 <|> flag' WarnOnly (long "warn")
@@ -189,12 +191,12 @@ parseLogCats s =
189191 return (concat cs)
190192
191193 parseLogCat :: ReadP [LogCat]
192− parseLogCat = (string "parser" *> return parserCats)
193− <|> (string "elab" *> return elabCats)
194− <|> (string "codegen" *> return codegenCats)
195− <|> (string "coverage" *> return [ICoverage])
196− <|> (string "ibc" *> return [IIBC])
197− <|> (string "erasure" *> return [IErasure])
194+ parseLogCat = (string (strLogCat IParse) *> return parserCats)
195+ <|> (string (strLogCat IElab) *> return elabCats)
196+ <|> (string (strLogCat ICodeGen) *> return codegenCats)
197+ <|> (string (strLogCat ICoverage) *> return [ICoverage])
198+ <|> (string (strLogCat IIBC) *> return [IIBC])
199+ <|> (string (strLogCat IErasure) *> return [IErasure])
198200 <|> parseLogCatBad
199201
200202 parseLogCatBad :: ReadP [LogCat]
src/Idris/DeepSeq.hs+1
@@ -107,6 +107,7 @@ instance NFData Opt where
107107 rnf (ColourREPL bool) = rnf bool `seq` ()
108108 rnf (Idemode) = ()
109109 rnf (IdemodeSocket) = ()
110+ rnf (ShowLoggingCats) = ()
110111 rnf (ShowLibs) = ()
111112 rnf (ShowLibdir) = ()
112113 rnf (ShowIncs) = ()
src/Idris/REPLParser.hs+6−6
@@ -407,12 +407,12 @@ cmd_cats name = do
407407 fail $ "Category: " ++ c ++ " is not recognised."
408408
409409 pLogCats :: P.IdrisParser [LogCat]
410− pLogCats = try (P.symbol "parser" >> return parserCats)
411− <|> try (P.symbol "elab" >> return elabCats)
412− <|> try (P.symbol "codegen" >> return codegenCats)
413− <|> try (P.symbol "coverage" >> return [ICoverage])
414− <|> try (P.symbol "ibc" >> return [IIBC])
415− <|> try (P.symbol "erasure" >> return [IErasure])
410+ pLogCats = try (P.symbol (strLogCat IParse) >> return parserCats)
411+ <|> try (P.symbol (strLogCat IElab) >> return elabCats)
412+ <|> try (P.symbol (strLogCat ICodeGen) >> return codegenCats)
413+ <|> try (P.symbol (strLogCat ICoverage) >> return [ICoverage])
414+ <|> try (P.symbol (strLogCat IIBC) >> return [IIBC])
415+ <|> try (P.symbol (strLogCat IErasure) >> return [IErasure])
416416 <|> badCat
417417
418418cmd_let :: String -> P.IdrisParser (Either String Command)