mirror of
https://github.com/github/semantic.git
synced 2024-12-29 01:42:43 +03:00
factor opts out of main
This commit is contained in:
parent
29e8048785
commit
d8757e898c
@ -13,6 +13,14 @@ import System.IO (FilePath)
|
||||
import Options.Applicative hiding (style)
|
||||
import Data.Semigroup ((<>))
|
||||
|
||||
main :: IO ()
|
||||
main = generateAST =<< execParser opts
|
||||
|
||||
opts :: ParserInfo SemanticAST
|
||||
opts = info (parseAST <**> helper)
|
||||
( fullDesc
|
||||
<> progDesc "Read a file, output an AST"
|
||||
<> header "semantic-ast - generates ASTs" )
|
||||
data SemanticAST = SemanticAST
|
||||
{ sourceFilePath :: Prelude.String
|
||||
, format :: Prelude.String
|
||||
@ -28,14 +36,6 @@ parseAST = SemanticAST
|
||||
( long "format"
|
||||
<> help "Specify format --json --sexpression --show" )
|
||||
|
||||
main :: IO ()
|
||||
main = generateAST =<< execParser opts
|
||||
where
|
||||
opts = info (parseAST <**> helper)
|
||||
( fullDesc
|
||||
<> progDesc "Read a file, output an AST"
|
||||
<> header "semantic-ast - generates ASTs" )
|
||||
|
||||
generateAST :: SemanticAST -> IO ()
|
||||
generateAST (SemanticAST file _) = do
|
||||
bytestring <- Data.ByteString.readFile file
|
||||
|
Loading…
Reference in New Issue
Block a user