From 6f76187c57e823f30776eb4faf73ff271875be6b Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Fri, 15 Feb 2019 09:26:33 -0800 Subject: [PATCH 1/2] This help text was incorrect --- src/Semantic/CLI.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Semantic/CLI.hs b/src/Semantic/CLI.hs index 10a3ee843..01f00ccac 100644 --- a/src/Semantic/CLI.hs +++ b/src/Semantic/CLI.hs @@ -84,7 +84,7 @@ parseCommand = command "parse" (info parseArgumentsParser (progDesc "Generate pa pure $ Task.readBlobs filesOrStdin >>= renderer tsParseCommand :: Mod CommandFields (Task.TaskEff Builder) -tsParseCommand = command "ts-parse" (info tsParseArgumentsParser (progDesc "Don't produce output, but show timing stats")) +tsParseCommand = command "ts-parse" (info tsParseArgumentsParser (progDesc "Generate raw tree-sitter parse trees for path(s)")) where tsParseArgumentsParser = do format <- flag AST.SExpression AST.SExpression (long "sexpression" <> help "Output s-expression ASTs (default)") From e3029bd89bf4726f069e1fa65e6e6604225586b3 Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Fri, 15 Feb 2019 09:28:52 -0800 Subject: [PATCH 2/2] Allow unknown languages through so we can diff against /dev/null --- src/Data/Language.hs | 6 ------ src/Semantic/CLI.hs | 8 ++++---- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/Data/Language.hs b/src/Data/Language.hs index 7441eef48..9a0a101c2 100644 --- a/src/Data/Language.hs +++ b/src/Data/Language.hs @@ -2,7 +2,6 @@ module Data.Language ( Language (..) , SLanguage (..) - , ensureLanguage , extensionsForLanguage , knownLanguage , languageForFilePath @@ -100,11 +99,6 @@ instance FromJSON Language where knownLanguage :: Language -> Bool knownLanguage = (/= Unknown) --- | Returns 'Nothing' when passed 'Unknown'. -ensureLanguage :: Language -> Maybe Language -ensureLanguage Unknown = Nothing -ensureLanguage x = Just x - -- | Defaults to 'Unknown'. instance HasDefault Language where def = Unknown diff --git a/src/Semantic/CLI.hs b/src/Semantic/CLI.hs index 01f00ccac..39921d347 100644 --- a/src/Semantic/CLI.hs +++ b/src/Semantic/CLI.hs @@ -3,7 +3,7 @@ module Semantic.CLI (main) where import Control.Exception as Exc (displayException) import Data.File -import Data.Language (ensureLanguage, languageForFilePath) +import Data.Language (languageForFilePath) import Data.List (intercalate, uncons) import Data.List.Split (splitWhen) import Data.Handle @@ -126,9 +126,9 @@ filePathReader :: ReadM File filePathReader = eitherReader parseFilePath where parseFilePath arg = case splitWhen (== ':') arg of - [a, b] | Just lang <- readMaybe b >>= ensureLanguage -> Right (File a lang) - | Just lang <- readMaybe a >>= ensureLanguage -> Right (File b lang) - [path] -> maybe (Left $ "Cannot identify language for path: " <> path) (Right . File path) (ensureLanguage (languageForFilePath path)) + [a, b] | Just lang <- readMaybe a -> Right (File a lang) + | Just lang <- readMaybe b -> Right (File b lang) + [path] -> Right (File path (languageForFilePath path)) args -> Left ("cannot parse `" <> join args <> "`\nexpecting FILE:LANGUAGE or just FILE") options :: Eq a => [(String, a)] -> Mod OptionFields a -> Parser a