{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Main (main) where
import Cardano.Crypto.Init (cryptoInit)
import Cardano.Tools.DBAnalyser.Block.Cardano
import Cardano.Tools.DBAnalyser.Run
import Cardano.Tools.DBAnalyser.Types
import Cardano.Tools.GitRev (gitRev)
import Control.Monad (void)
import DBAnalyser.Parsers
import qualified Data.Text as T
import Main.Utf8 (withStdTerminalHandles)
import Options.Applicative
( execParser
, footer
, fullDesc
, helper
, info
, progDesc
, (<**>)
)
main :: IO ()
IO ()
main = IO () -> IO ()
forall (m :: * -> *) r. (MonadIO m, MonadMask m) => m r -> m r
withStdTerminalHandles (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ do
IO ()
cryptoInit
IO (Maybe AnalysisResult) -> IO ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (IO (Maybe AnalysisResult) -> IO ())
-> IO (Maybe AnalysisResult) -> IO ()
forall a b. (a -> b) -> a -> b
$ (DBAnalyserConfig
-> Args (CardanoBlock StandardCrypto) -> IO (Maybe AnalysisResult))
-> (DBAnalyserConfig, Args (CardanoBlock StandardCrypto))
-> IO (Maybe AnalysisResult)
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry DBAnalyserConfig
-> Args (CardanoBlock StandardCrypto) -> IO (Maybe AnalysisResult)
forall blk.
(RunNode blk, Show (Header blk), HasAnalysis blk,
HasProtocolInfo blk, HasTxs blk,
CanStowLedgerTables (LedgerState blk)) =>
DBAnalyserConfig -> Args blk -> IO (Maybe AnalysisResult)
analyse ((DBAnalyserConfig, Args (CardanoBlock StandardCrypto))
-> IO (Maybe AnalysisResult))
-> IO (DBAnalyserConfig, Args (CardanoBlock StandardCrypto))
-> IO (Maybe AnalysisResult)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (DBAnalyserConfig, Args (CardanoBlock StandardCrypto))
getCmdLine
getCmdLine :: IO (DBAnalyserConfig, CardanoBlockArgs)
getCmdLine :: IO (DBAnalyserConfig, Args (CardanoBlock StandardCrypto))
getCmdLine = ParserInfo (DBAnalyserConfig, Args (CardanoBlock StandardCrypto))
-> IO (DBAnalyserConfig, Args (CardanoBlock StandardCrypto))
forall a. ParserInfo a -> IO a
execParser ParserInfo (DBAnalyserConfig, Args (CardanoBlock StandardCrypto))
opts
where
opts :: ParserInfo (DBAnalyserConfig, Args (CardanoBlock StandardCrypto))
opts =
Parser (DBAnalyserConfig, Args (CardanoBlock StandardCrypto))
-> InfoMod (DBAnalyserConfig, Args (CardanoBlock StandardCrypto))
-> ParserInfo
(DBAnalyserConfig, Args (CardanoBlock StandardCrypto))
forall a. Parser a -> InfoMod a -> ParserInfo a
info
(Parser (DBAnalyserConfig, Args (CardanoBlock StandardCrypto))
parseCmdLine Parser (DBAnalyserConfig, Args (CardanoBlock StandardCrypto))
-> Parser
((DBAnalyserConfig, Args (CardanoBlock StandardCrypto))
-> (DBAnalyserConfig, Args (CardanoBlock StandardCrypto)))
-> Parser (DBAnalyserConfig, Args (CardanoBlock StandardCrypto))
forall (f :: * -> *) a b. Applicative f => f a -> f (a -> b) -> f b
<**> Parser
((DBAnalyserConfig, Args (CardanoBlock StandardCrypto))
-> (DBAnalyserConfig, Args (CardanoBlock StandardCrypto)))
forall a. Parser (a -> a)
helper)
( [InfoMod (DBAnalyserConfig, Args (CardanoBlock StandardCrypto))]
-> InfoMod (DBAnalyserConfig, Args (CardanoBlock StandardCrypto))
forall a. Monoid a => [a] -> a
mconcat
[ InfoMod (DBAnalyserConfig, Args (CardanoBlock StandardCrypto))
forall a. InfoMod a
fullDesc
, String
-> InfoMod (DBAnalyserConfig, Args (CardanoBlock StandardCrypto))
forall a. String -> InfoMod a
progDesc String
"Simple framework used to analyse a Chain DB"
, String
-> InfoMod (DBAnalyserConfig, Args (CardanoBlock StandardCrypto))
forall a. String -> InfoMod a
footer (String
-> InfoMod (DBAnalyserConfig, Args (CardanoBlock StandardCrypto)))
-> String
-> InfoMod (DBAnalyserConfig, Args (CardanoBlock StandardCrypto))
forall a b. (a -> b) -> a -> b
$ String
"ouroboros-consensus commit: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Text -> String
T.unpack Text
gitRev
]
)