module DBSynthesizer.Parsers (parseCommandLine) where import Cardano.Tools.DBSynthesizer.Types import Data.Word (Word64) import Options.Applicative as Opt import Ouroboros.Consensus.Block.Abstract (SlotNo (..)) parseCommandLine :: IO (NodeFilePaths, NodeCredentials, DBSynthesizerOptions) parseCommandLine :: IO (NodeFilePaths, NodeCredentials, DBSynthesizerOptions) parseCommandLine = ParserPrefs -> ParserInfo (NodeFilePaths, NodeCredentials, DBSynthesizerOptions) -> IO (NodeFilePaths, NodeCredentials, DBSynthesizerOptions) forall a. ParserPrefs -> ParserInfo a -> IO a Opt.customExecParser ParserPrefs p ParserInfo (NodeFilePaths, NodeCredentials, DBSynthesizerOptions) opts where p :: ParserPrefs p = PrefsMod -> ParserPrefs Opt.prefs PrefsMod Opt.showHelpOnEmpty opts :: ParserInfo (NodeFilePaths, NodeCredentials, DBSynthesizerOptions) opts = Parser (NodeFilePaths, NodeCredentials, DBSynthesizerOptions) -> InfoMod (NodeFilePaths, NodeCredentials, DBSynthesizerOptions) -> ParserInfo (NodeFilePaths, NodeCredentials, DBSynthesizerOptions) forall a. Parser a -> InfoMod a -> ParserInfo a Opt.info Parser (NodeFilePaths, NodeCredentials, DBSynthesizerOptions) parserCommandLine InfoMod (NodeFilePaths, NodeCredentials, DBSynthesizerOptions) forall a. Monoid a => a mempty parserCommandLine :: Parser (NodeFilePaths, NodeCredentials, DBSynthesizerOptions) parserCommandLine :: Parser (NodeFilePaths, NodeCredentials, DBSynthesizerOptions) parserCommandLine = (,,) (NodeFilePaths -> NodeCredentials -> DBSynthesizerOptions -> (NodeFilePaths, NodeCredentials, DBSynthesizerOptions)) -> Parser NodeFilePaths -> Parser (NodeCredentials -> DBSynthesizerOptions -> (NodeFilePaths, NodeCredentials, DBSynthesizerOptions)) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Parser NodeFilePaths parseNodeFilePaths Parser (NodeCredentials -> DBSynthesizerOptions -> (NodeFilePaths, NodeCredentials, DBSynthesizerOptions)) -> Parser NodeCredentials -> Parser (DBSynthesizerOptions -> (NodeFilePaths, NodeCredentials, DBSynthesizerOptions)) forall a b. Parser (a -> b) -> Parser a -> Parser b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Parser NodeCredentials parseNodeCredentials Parser (DBSynthesizerOptions -> (NodeFilePaths, NodeCredentials, DBSynthesizerOptions)) -> Parser DBSynthesizerOptions -> Parser (NodeFilePaths, NodeCredentials, DBSynthesizerOptions) forall a b. Parser (a -> b) -> Parser a -> Parser b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Parser DBSynthesizerOptions parseDBSynthesizerOptions parseNodeFilePaths :: Parser NodeFilePaths parseNodeFilePaths :: Parser NodeFilePaths parseNodeFilePaths = FilePath -> FilePath -> NodeFilePaths NodeFilePaths (FilePath -> FilePath -> NodeFilePaths) -> Parser FilePath -> Parser (FilePath -> NodeFilePaths) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Parser FilePath parseNodeConfigFilePath Parser (FilePath -> NodeFilePaths) -> Parser FilePath -> Parser NodeFilePaths forall a b. Parser (a -> b) -> Parser a -> Parser b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Parser FilePath parseChainDBFilePath parseNodeCredentials :: Parser NodeCredentials parseNodeCredentials :: Parser NodeCredentials parseNodeCredentials = Maybe FilePath -> Maybe FilePath -> Maybe FilePath -> Maybe FilePath -> NodeCredentials NodeCredentials (Maybe FilePath -> Maybe FilePath -> Maybe FilePath -> Maybe FilePath -> NodeCredentials) -> Parser (Maybe FilePath) -> Parser (Maybe FilePath -> Maybe FilePath -> Maybe FilePath -> NodeCredentials) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Parser FilePath -> Parser (Maybe FilePath) forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a) optional Parser FilePath parseOperationalCertFilePath Parser (Maybe FilePath -> Maybe FilePath -> Maybe FilePath -> NodeCredentials) -> Parser (Maybe FilePath) -> Parser (Maybe FilePath -> Maybe FilePath -> NodeCredentials) forall a b. Parser (a -> b) -> Parser a -> Parser b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Parser FilePath -> Parser (Maybe FilePath) forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a) optional Parser FilePath parseVrfKeyFilePath Parser (Maybe FilePath -> Maybe FilePath -> NodeCredentials) -> Parser (Maybe FilePath) -> Parser (Maybe FilePath -> NodeCredentials) forall a b. Parser (a -> b) -> Parser a -> Parser b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Parser FilePath -> Parser (Maybe FilePath) forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a) optional Parser FilePath parseKesKeyFilePath Parser (Maybe FilePath -> NodeCredentials) -> Parser (Maybe FilePath) -> Parser NodeCredentials forall a b. Parser (a -> b) -> Parser a -> Parser b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Parser FilePath -> Parser (Maybe FilePath) forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a) optional Parser FilePath parseBulkFilePath parseDBSynthesizerOptions :: Parser DBSynthesizerOptions parseDBSynthesizerOptions :: Parser DBSynthesizerOptions parseDBSynthesizerOptions = ForgeLimit -> DBSynthesizerOpenMode -> DBSynthesizerOptions DBSynthesizerOptions (ForgeLimit -> DBSynthesizerOpenMode -> DBSynthesizerOptions) -> Parser ForgeLimit -> Parser (DBSynthesizerOpenMode -> DBSynthesizerOptions) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Parser ForgeLimit parseForgeOptions Parser (DBSynthesizerOpenMode -> DBSynthesizerOptions) -> Parser DBSynthesizerOpenMode -> Parser DBSynthesizerOptions forall a b. Parser (a -> b) -> Parser a -> Parser b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Parser DBSynthesizerOpenMode parseOpenMode parseForgeOptions :: Parser ForgeLimit parseForgeOptions :: Parser ForgeLimit parseForgeOptions = SlotNo -> ForgeLimit ForgeLimitSlot (SlotNo -> ForgeLimit) -> Parser SlotNo -> Parser ForgeLimit forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Parser SlotNo parseSlotLimit Parser ForgeLimit -> Parser ForgeLimit -> Parser ForgeLimit forall a. Parser a -> Parser a -> Parser a forall (f :: * -> *) a. Alternative f => f a -> f a -> f a <|> Word64 -> ForgeLimit ForgeLimitBlock (Word64 -> ForgeLimit) -> Parser Word64 -> Parser ForgeLimit forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Parser Word64 parseBlockLimit Parser ForgeLimit -> Parser ForgeLimit -> Parser ForgeLimit forall a. Parser a -> Parser a -> Parser a forall (f :: * -> *) a. Alternative f => f a -> f a -> f a <|> Word64 -> ForgeLimit ForgeLimitEpoch (Word64 -> ForgeLimit) -> Parser Word64 -> Parser ForgeLimit forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Parser Word64 parseEpochLimit parseChainDBFilePath :: Parser FilePath parseChainDBFilePath :: Parser FilePath parseChainDBFilePath = Mod OptionFields FilePath -> Parser FilePath forall s. IsString s => Mod OptionFields s -> Parser s strOption ( FilePath -> Mod OptionFields FilePath forall (f :: * -> *) a. HasName f => FilePath -> Mod f a long FilePath "db" Mod OptionFields FilePath -> Mod OptionFields FilePath -> Mod OptionFields FilePath forall a. Semigroup a => a -> a -> a <> FilePath -> Mod OptionFields FilePath forall (f :: * -> *) a. HasMetavar f => FilePath -> Mod f a metavar FilePath "PATH" Mod OptionFields FilePath -> Mod OptionFields FilePath -> Mod OptionFields FilePath forall a. Semigroup a => a -> a -> a <> FilePath -> Mod OptionFields FilePath forall (f :: * -> *) a. FilePath -> Mod f a help FilePath "Path to the Chain DB" Mod OptionFields FilePath -> Mod OptionFields FilePath -> Mod OptionFields FilePath forall a. Semigroup a => a -> a -> a <> Completer -> Mod OptionFields FilePath forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a completer (FilePath -> Completer bashCompleter FilePath "directory") ) parseNodeConfigFilePath :: Parser FilePath parseNodeConfigFilePath :: Parser FilePath parseNodeConfigFilePath = Mod OptionFields FilePath -> Parser FilePath forall s. IsString s => Mod OptionFields s -> Parser s strOption ( FilePath -> Mod OptionFields FilePath forall (f :: * -> *) a. HasName f => FilePath -> Mod f a long FilePath "config" Mod OptionFields FilePath -> Mod OptionFields FilePath -> Mod OptionFields FilePath forall a. Semigroup a => a -> a -> a <> FilePath -> Mod OptionFields FilePath forall (f :: * -> *) a. HasMetavar f => FilePath -> Mod f a metavar FilePath "FILE" Mod OptionFields FilePath -> Mod OptionFields FilePath -> Mod OptionFields FilePath forall a. Semigroup a => a -> a -> a <> FilePath -> Mod OptionFields FilePath forall (f :: * -> *) a. FilePath -> Mod f a help FilePath "Path to the node's config.json" Mod OptionFields FilePath -> Mod OptionFields FilePath -> Mod OptionFields FilePath forall a. Semigroup a => a -> a -> a <> Completer -> Mod OptionFields FilePath forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a completer (FilePath -> Completer bashCompleter FilePath "file") ) parseOperationalCertFilePath :: Parser FilePath parseOperationalCertFilePath :: Parser FilePath parseOperationalCertFilePath = Mod OptionFields FilePath -> Parser FilePath forall s. IsString s => Mod OptionFields s -> Parser s strOption ( FilePath -> Mod OptionFields FilePath forall (f :: * -> *) a. HasName f => FilePath -> Mod f a long FilePath "shelley-operational-certificate" Mod OptionFields FilePath -> Mod OptionFields FilePath -> Mod OptionFields FilePath forall a. Semigroup a => a -> a -> a <> FilePath -> Mod OptionFields FilePath forall (f :: * -> *) a. HasMetavar f => FilePath -> Mod f a metavar FilePath "FILE" Mod OptionFields FilePath -> Mod OptionFields FilePath -> Mod OptionFields FilePath forall a. Semigroup a => a -> a -> a <> FilePath -> Mod OptionFields FilePath forall (f :: * -> *) a. FilePath -> Mod f a help FilePath "Path to the delegation certificate" Mod OptionFields FilePath -> Mod OptionFields FilePath -> Mod OptionFields FilePath forall a. Semigroup a => a -> a -> a <> Completer -> Mod OptionFields FilePath forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a completer (FilePath -> Completer bashCompleter FilePath "file") ) parseKesKeyFilePath :: Parser FilePath parseKesKeyFilePath :: Parser FilePath parseKesKeyFilePath = Mod OptionFields FilePath -> Parser FilePath forall s. IsString s => Mod OptionFields s -> Parser s strOption ( FilePath -> Mod OptionFields FilePath forall (f :: * -> *) a. HasName f => FilePath -> Mod f a long FilePath "shelley-kes-key" Mod OptionFields FilePath -> Mod OptionFields FilePath -> Mod OptionFields FilePath forall a. Semigroup a => a -> a -> a <> FilePath -> Mod OptionFields FilePath forall (f :: * -> *) a. HasMetavar f => FilePath -> Mod f a metavar FilePath "FILE" Mod OptionFields FilePath -> Mod OptionFields FilePath -> Mod OptionFields FilePath forall a. Semigroup a => a -> a -> a <> FilePath -> Mod OptionFields FilePath forall (f :: * -> *) a. FilePath -> Mod f a help FilePath "Path to the KES signing key" Mod OptionFields FilePath -> Mod OptionFields FilePath -> Mod OptionFields FilePath forall a. Semigroup a => a -> a -> a <> Completer -> Mod OptionFields FilePath forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a completer (FilePath -> Completer bashCompleter FilePath "file") ) parseVrfKeyFilePath :: Parser FilePath parseVrfKeyFilePath :: Parser FilePath parseVrfKeyFilePath = Mod OptionFields FilePath -> Parser FilePath forall s. IsString s => Mod OptionFields s -> Parser s strOption ( FilePath -> Mod OptionFields FilePath forall (f :: * -> *) a. HasName f => FilePath -> Mod f a long FilePath "shelley-vrf-key" Mod OptionFields FilePath -> Mod OptionFields FilePath -> Mod OptionFields FilePath forall a. Semigroup a => a -> a -> a <> FilePath -> Mod OptionFields FilePath forall (f :: * -> *) a. HasMetavar f => FilePath -> Mod f a metavar FilePath "FILE" Mod OptionFields FilePath -> Mod OptionFields FilePath -> Mod OptionFields FilePath forall a. Semigroup a => a -> a -> a <> FilePath -> Mod OptionFields FilePath forall (f :: * -> *) a. FilePath -> Mod f a help FilePath "Path to the VRF signing key" Mod OptionFields FilePath -> Mod OptionFields FilePath -> Mod OptionFields FilePath forall a. Semigroup a => a -> a -> a <> Completer -> Mod OptionFields FilePath forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a completer (FilePath -> Completer bashCompleter FilePath "file") ) parseBulkFilePath :: Parser FilePath parseBulkFilePath :: Parser FilePath parseBulkFilePath = Mod OptionFields FilePath -> Parser FilePath forall s. IsString s => Mod OptionFields s -> Parser s strOption ( FilePath -> Mod OptionFields FilePath forall (f :: * -> *) a. HasName f => FilePath -> Mod f a long FilePath "bulk-credentials-file" Mod OptionFields FilePath -> Mod OptionFields FilePath -> Mod OptionFields FilePath forall a. Semigroup a => a -> a -> a <> FilePath -> Mod OptionFields FilePath forall (f :: * -> *) a. HasMetavar f => FilePath -> Mod f a metavar FilePath "FILE" Mod OptionFields FilePath -> Mod OptionFields FilePath -> Mod OptionFields FilePath forall a. Semigroup a => a -> a -> a <> FilePath -> Mod OptionFields FilePath forall (f :: * -> *) a. FilePath -> Mod f a help FilePath "Path to the bulk credentials file" Mod OptionFields FilePath -> Mod OptionFields FilePath -> Mod OptionFields FilePath forall a. Semigroup a => a -> a -> a <> Completer -> Mod OptionFields FilePath forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a completer (FilePath -> Completer bashCompleter FilePath "file") ) parseSlotLimit :: Parser SlotNo parseSlotLimit :: Parser SlotNo parseSlotLimit = Word64 -> SlotNo SlotNo (Word64 -> SlotNo) -> Parser Word64 -> Parser SlotNo forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> ReadM Word64 -> Mod OptionFields Word64 -> Parser Word64 forall a. ReadM a -> Mod OptionFields a -> Parser a option ReadM Word64 forall a. Read a => ReadM a auto ( Char -> Mod OptionFields Word64 forall (f :: * -> *) a. HasName f => Char -> Mod f a short Char 's' Mod OptionFields Word64 -> Mod OptionFields Word64 -> Mod OptionFields Word64 forall a. Semigroup a => a -> a -> a <> FilePath -> Mod OptionFields Word64 forall (f :: * -> *) a. HasName f => FilePath -> Mod f a long FilePath "slots" Mod OptionFields Word64 -> Mod OptionFields Word64 -> Mod OptionFields Word64 forall a. Semigroup a => a -> a -> a <> FilePath -> Mod OptionFields Word64 forall (f :: * -> *) a. HasMetavar f => FilePath -> Mod f a metavar FilePath "NUMBER" Mod OptionFields Word64 -> Mod OptionFields Word64 -> Mod OptionFields Word64 forall a. Semigroup a => a -> a -> a <> FilePath -> Mod OptionFields Word64 forall (f :: * -> *) a. FilePath -> Mod f a help FilePath "Amount of slots to process" ) parseBlockLimit :: Parser Word64 parseBlockLimit :: Parser Word64 parseBlockLimit = ReadM Word64 -> Mod OptionFields Word64 -> Parser Word64 forall a. ReadM a -> Mod OptionFields a -> Parser a option ReadM Word64 forall a. Read a => ReadM a auto ( Char -> Mod OptionFields Word64 forall (f :: * -> *) a. HasName f => Char -> Mod f a short Char 'b' Mod OptionFields Word64 -> Mod OptionFields Word64 -> Mod OptionFields Word64 forall a. Semigroup a => a -> a -> a <> FilePath -> Mod OptionFields Word64 forall (f :: * -> *) a. HasName f => FilePath -> Mod f a long FilePath "blocks" Mod OptionFields Word64 -> Mod OptionFields Word64 -> Mod OptionFields Word64 forall a. Semigroup a => a -> a -> a <> FilePath -> Mod OptionFields Word64 forall (f :: * -> *) a. HasMetavar f => FilePath -> Mod f a metavar FilePath "NUMBER" Mod OptionFields Word64 -> Mod OptionFields Word64 -> Mod OptionFields Word64 forall a. Semigroup a => a -> a -> a <> FilePath -> Mod OptionFields Word64 forall (f :: * -> *) a. FilePath -> Mod f a help FilePath "Amount of blocks to forge" ) parseEpochLimit :: Parser Word64 parseEpochLimit :: Parser Word64 parseEpochLimit = ReadM Word64 -> Mod OptionFields Word64 -> Parser Word64 forall a. ReadM a -> Mod OptionFields a -> Parser a option ReadM Word64 forall a. Read a => ReadM a auto ( Char -> Mod OptionFields Word64 forall (f :: * -> *) a. HasName f => Char -> Mod f a short Char 'e' Mod OptionFields Word64 -> Mod OptionFields Word64 -> Mod OptionFields Word64 forall a. Semigroup a => a -> a -> a <> FilePath -> Mod OptionFields Word64 forall (f :: * -> *) a. HasName f => FilePath -> Mod f a long FilePath "epochs" Mod OptionFields Word64 -> Mod OptionFields Word64 -> Mod OptionFields Word64 forall a. Semigroup a => a -> a -> a <> FilePath -> Mod OptionFields Word64 forall (f :: * -> *) a. HasMetavar f => FilePath -> Mod f a metavar FilePath "NUMBER" Mod OptionFields Word64 -> Mod OptionFields Word64 -> Mod OptionFields Word64 forall a. Semigroup a => a -> a -> a <> FilePath -> Mod OptionFields Word64 forall (f :: * -> *) a. FilePath -> Mod f a help FilePath "Amount of epochs to process" ) parseForce :: Parser Bool parseForce :: Parser Bool parseForce = Mod FlagFields Bool -> Parser Bool switch ( Char -> Mod FlagFields Bool forall (f :: * -> *) a. HasName f => Char -> Mod f a short Char 'f' Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool forall a. Semigroup a => a -> a -> a <> FilePath -> Mod FlagFields Bool forall (f :: * -> *) a. FilePath -> Mod f a help FilePath "Force overwrite an existing Chain DB" ) parseAppend :: Parser Bool parseAppend :: Parser Bool parseAppend = Mod FlagFields Bool -> Parser Bool switch ( Char -> Mod FlagFields Bool forall (f :: * -> *) a. HasName f => Char -> Mod f a short Char 'a' Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool forall a. Semigroup a => a -> a -> a <> FilePath -> Mod FlagFields Bool forall (f :: * -> *) a. FilePath -> Mod f a help FilePath "Append to an existing Chain DB" ) parseOpenMode :: Parser DBSynthesizerOpenMode parseOpenMode :: Parser DBSynthesizerOpenMode parseOpenMode = (Parser Bool parseForce Parser Bool -> Parser DBSynthesizerOpenMode -> Parser DBSynthesizerOpenMode forall a b. Parser a -> Parser b -> Parser b forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b *> DBSynthesizerOpenMode -> Parser DBSynthesizerOpenMode forall a. a -> Parser a forall (f :: * -> *) a. Applicative f => a -> f a pure DBSynthesizerOpenMode OpenCreateForce) Parser DBSynthesizerOpenMode -> Parser DBSynthesizerOpenMode -> Parser DBSynthesizerOpenMode forall a. Parser a -> Parser a -> Parser a forall (f :: * -> *) a. Alternative f => f a -> f a -> f a <|> (Parser Bool parseAppend Parser Bool -> Parser DBSynthesizerOpenMode -> Parser DBSynthesizerOpenMode forall a b. Parser a -> Parser b -> Parser b forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b *> DBSynthesizerOpenMode -> Parser DBSynthesizerOpenMode forall a. a -> Parser a forall (f :: * -> *) a. Applicative f => a -> f a pure DBSynthesizerOpenMode OpenAppend) Parser DBSynthesizerOpenMode -> Parser DBSynthesizerOpenMode -> Parser DBSynthesizerOpenMode forall a. Parser a -> Parser a -> Parser a forall (f :: * -> *) a. Alternative f => f a -> f a -> f a <|> DBSynthesizerOpenMode -> Parser DBSynthesizerOpenMode forall a. a -> Parser a forall (f :: * -> *) a. Applicative f => a -> f a pure DBSynthesizerOpenMode OpenCreate