From 89e5168e65da7661fad27e25f4a798d9f7c1eff9 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 May 2018 17:23:06 -0400 Subject: [PATCH] Extract symbolFieldsReader to the top level. --- src/Semantic/CLI.hs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/Semantic/CLI.hs b/src/Semantic/CLI.hs index bfbb92f82..f092dd6f4 100644 --- a/src/Semantic/CLI.hs +++ b/src/Semantic/CLI.hs @@ -121,14 +121,16 @@ arguments = info (version <*> helper <*> ((,) <$> optionsParser <*> argumentsPar options options fields = option (optionsReader options) (fields <> showDefaultWith (findOption options) <> metavar (intercalate "|" (fmap fst options))) findOption options value = maybe "" fst (find ((== value) . snd) options) - -- Example: semantic parse --symbols --fields=symbol,path,language,kind,line,span - symbolFieldsReader = eitherReader parseSymbolFields - parseSymbolFields arg = let fields = splitWhen (== ',') arg in - Right SymbolFields - { symbolFieldsName = "symbol" `elem` fields - , symbolFieldsPath = "path" `elem` fields - , symbolFieldsLang = "language" `elem` fields - , symbolFieldsKind = "kind" `elem` fields - , symbolFieldsLine = "line" `elem` fields - , symbolFieldsSpan = "span" `elem` fields - } + +-- Example: semantic parse --symbols --fields=symbol,path,language,kind,line,span +symbolFieldsReader :: ReadM SymbolFields +symbolFieldsReader = eitherReader parseSymbolFields + where parseSymbolFields arg = let fields = splitWhen (== ',') arg in + Right SymbolFields + { symbolFieldsName = "symbol" `elem` fields + , symbolFieldsPath = "path" `elem` fields + , symbolFieldsLang = "language" `elem` fields + , symbolFieldsKind = "kind" `elem` fields + , symbolFieldsLine = "line" `elem` fields + , symbolFieldsSpan = "span" `elem` fields + }