1
1
mirror of https://github.com/github/semantic.git synced 2024-12-29 18:06:14 +03:00

Remove CLI parser for git repo stuff.

This commit is contained in:
Patrick Thomson 2019-10-21 16:36:42 -04:00
parent 52243cfb07
commit 9acb44abe4

View File

@ -6,7 +6,6 @@ import Control.Effect.Reader
import Control.Exception as Exc (displayException) import Control.Exception as Exc (displayException)
import Data.Blob import Data.Blob
import Data.Blob.IO import Data.Blob.IO
import qualified Data.ByteString.Char8 as B
import Data.Handle import Data.Handle
import qualified Data.Language as Language import qualified Data.Language as Language
import Data.List (intercalate) import Data.List (intercalate)
@ -18,7 +17,6 @@ import Semantic.Api hiding (File)
import Semantic.Config import Semantic.Config
import qualified Semantic.Graph as Graph import qualified Semantic.Graph as Graph
import qualified Semantic.Task as Task import qualified Semantic.Task as Task
import qualified Semantic.Git as Git
import Semantic.Task.Files import Semantic.Task.Files
import Semantic.Telemetry import Semantic.Telemetry
import qualified Semantic.Telemetry.Log as Log import qualified Semantic.Telemetry.Log as Log
@ -134,14 +132,7 @@ parseCommand = command "parse" (info parseArgumentsParser (progDesc "Generate pa
<|> flag' (parseTermBuilder TermQuiet) <|> flag' (parseTermBuilder TermQuiet)
( long "quiet" ( long "quiet"
<> help "Don't produce output, but show timing stats") <> help "Don't produce output, but show timing stats")
filesOrStdin <- FilesFromGitRepo filesOrStdin <- FilesFromPaths <$> some (argument filePathReader (metavar "FILES..."))
<$> option str (long "gitDir" <> help "A .git directory to read from")
<*> option shaReader (long "sha" <> help "The commit SHA1 to read from")
<*> ( ExcludePaths <$> many (option str (long "exclude" <> short 'x' <> help "Paths to exclude"))
<|> ExcludeFromHandle <$> flag' stdin (long "exclude-stdin" <> help "Exclude paths given to stdin")
<|> IncludePaths <$> many (option str (long "only" <> help "Only include the specified paths"))
<|> IncludePathsFromHandle <$> flag' stdin (long "only-stdin" <> help "Include only the paths given to stdin"))
<|> FilesFromPaths <$> some (argument filePathReader (metavar "FILES..."))
<|> pure (FilesFromHandle stdin) <|> pure (FilesFromHandle stdin)
pure $ Task.readBlobs filesOrStdin >>= runReader languageModes . renderer pure $ Task.readBlobs filesOrStdin >>= runReader languageModes . renderer
@ -183,12 +174,6 @@ languageModes = Language.PerLanguageModes
<> value Language.ALaCarte <> value Language.ALaCarte
<> showDefault) <> showDefault)
shaReader :: ReadM Git.OID
shaReader = eitherReader parseSha
where parseSha arg = if length arg == 40 || arg == "HEAD"
then Right (Git.OID (B.pack arg))
else Left (arg <> " is not a valid sha1")
filePathReader :: ReadM File filePathReader :: ReadM File
filePathReader = fileForPath <$> str filePathReader = fileForPath <$> str