1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 22:31:36 +03:00

Extract symbolFieldsReader to the top level.

This commit is contained in:
Rob Rix 2018-05-11 17:23:06 -04:00
parent 8bb2793804
commit 89e5168e65

View File

@ -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
}