{-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE ScopedTypeVariables #-} module Cardano.CLI.EraIndependent.Debug.Option ( parseDebugCmds ) where import Cardano.Api import Cardano.CLI.Environment import Cardano.CLI.EraBased.Common.Option import Cardano.CLI.EraIndependent.Debug.CheckNodeConfiguration.Command import Cardano.CLI.EraIndependent.Debug.Command import Cardano.CLI.EraIndependent.Debug.LogEpochState.Command import Cardano.CLI.EraIndependent.Debug.TransactionView.Command import Cardano.CLI.Option.Flag import Cardano.CLI.Parser import Data.Foldable import Data.Function ((&)) import Options.Applicative hiding (help, str) import Options.Applicative qualified as Opt parseDebugCmds :: EnvCli -> Parser DebugCmds parseDebugCmds :: EnvCli -> Parser DebugCmds parseDebugCmds EnvCli envCli = Mod CommandFields DebugCmds -> Parser DebugCmds forall a. Mod CommandFields a -> Parser a Opt.hsubparser (Mod CommandFields DebugCmds -> Parser DebugCmds) -> Mod CommandFields DebugCmds -> Parser DebugCmds forall a b. (a -> b) -> a -> b $ [Mod CommandFields DebugCmds] -> Mod CommandFields DebugCmds forall a. Monoid a => [a] -> a mconcat [ String -> Mod CommandFields DebugCmds forall (f :: * -> *) a. HasMetavar f => String -> Mod f a Opt.metavar String "debug commands" , String -> ParserInfo DebugCmds -> Mod CommandFields DebugCmds forall a. String -> ParserInfo a -> Mod CommandFields a Opt.command String "debug" (ParserInfo DebugCmds -> Mod CommandFields DebugCmds) -> ParserInfo DebugCmds -> Mod CommandFields DebugCmds forall a b. (a -> b) -> a -> b $ Parser DebugCmds -> InfoMod DebugCmds -> ParserInfo DebugCmds forall a. Parser a -> InfoMod a -> ParserInfo a Opt.info (EnvCli -> Parser DebugCmds pDebugCmds EnvCli envCli) (InfoMod DebugCmds -> ParserInfo DebugCmds) -> InfoMod DebugCmds -> ParserInfo DebugCmds forall a b. (a -> b) -> a -> b $ String -> InfoMod DebugCmds forall a. String -> InfoMod a Opt.progDesc String "Debug commands" ] pDebugCmds :: EnvCli -> Parser DebugCmds pDebugCmds :: EnvCli -> Parser DebugCmds pDebugCmds EnvCli envCli = [Parser DebugCmds] -> Parser DebugCmds forall (t :: * -> *) (f :: * -> *) a. (Foldable t, Alternative f) => t (f a) -> f a asum [ Mod CommandFields DebugCmds -> Parser DebugCmds forall a. Mod CommandFields a -> Parser a Opt.hsubparser (Mod CommandFields DebugCmds -> Parser DebugCmds) -> Mod CommandFields DebugCmds -> Parser DebugCmds forall a b. (a -> b) -> a -> b $ String -> ParserInfo DebugCmds -> Mod CommandFields DebugCmds forall a. String -> ParserInfo a -> Mod CommandFields a commandWithMetavar String "log-epoch-state" (ParserInfo DebugCmds -> Mod CommandFields DebugCmds) -> ParserInfo DebugCmds -> Mod CommandFields DebugCmds forall a b. (a -> b) -> a -> b $ Parser DebugCmds -> InfoMod DebugCmds -> ParserInfo DebugCmds forall a. Parser a -> InfoMod a -> ParserInfo a Opt.info Parser DebugCmds pLogEpochStateCmdArgs (InfoMod DebugCmds -> ParserInfo DebugCmds) -> InfoMod DebugCmds -> ParserInfo DebugCmds forall a b. (a -> b) -> a -> b $ String -> InfoMod DebugCmds forall a. String -> InfoMod a Opt.progDesc (String -> InfoMod DebugCmds) -> String -> InfoMod DebugCmds forall a b. (a -> b) -> a -> b $ [String] -> String forall a. Monoid a => [a] -> a mconcat [ String "Log epoch state of a running node." , String " This command will connect to a local node and log the epoch state to a file." , String " The log file format is line delimited JSON." , String " The command will not terminate." ] , Mod CommandFields DebugCmds -> Parser DebugCmds forall a. Mod CommandFields a -> Parser a Opt.hsubparser (Mod CommandFields DebugCmds -> Parser DebugCmds) -> Mod CommandFields DebugCmds -> Parser DebugCmds forall a b. (a -> b) -> a -> b $ String -> ParserInfo DebugCmds -> Mod CommandFields DebugCmds forall a. String -> ParserInfo a -> Mod CommandFields a commandWithMetavar String "check-node-configuration" (ParserInfo DebugCmds -> Mod CommandFields DebugCmds) -> ParserInfo DebugCmds -> Mod CommandFields DebugCmds forall a b. (a -> b) -> a -> b $ Parser DebugCmds -> InfoMod DebugCmds -> ParserInfo DebugCmds forall a. Parser a -> InfoMod a -> ParserInfo a Opt.info Parser DebugCmds pCheckNodeConfigurationCmdArgs (InfoMod DebugCmds -> ParserInfo DebugCmds) -> InfoMod DebugCmds -> ParserInfo DebugCmds forall a b. (a -> b) -> a -> b $ String -> InfoMod DebugCmds forall a. String -> InfoMod a Opt.progDesc String "Check hashes and paths of genesis files in the given node configuration file." , Mod CommandFields DebugCmds -> Parser DebugCmds forall a. Mod CommandFields a -> Parser a Opt.hsubparser (Mod CommandFields DebugCmds -> Parser DebugCmds) -> Mod CommandFields DebugCmds -> Parser DebugCmds forall a b. (a -> b) -> a -> b $ String -> ParserInfo DebugCmds -> Mod CommandFields DebugCmds forall a. String -> ParserInfo a -> Mod CommandFields a commandWithMetavar String "transaction" (ParserInfo DebugCmds -> Mod CommandFields DebugCmds) -> ParserInfo DebugCmds -> Mod CommandFields DebugCmds forall a b. (a -> b) -> a -> b $ Parser DebugCmds -> InfoMod DebugCmds -> ParserInfo DebugCmds forall a. Parser a -> InfoMod a -> ParserInfo a Opt.info ( [Parser DebugCmds] -> Parser DebugCmds forall (t :: * -> *) (f :: * -> *) a. (Foldable t, Alternative f) => t (f a) -> f a asum [ Mod CommandFields DebugCmds -> Parser DebugCmds forall a. Mod CommandFields a -> Parser a Opt.hsubparser (Mod CommandFields DebugCmds -> Parser DebugCmds) -> Mod CommandFields DebugCmds -> Parser DebugCmds forall a b. (a -> b) -> a -> b $ String -> ParserInfo DebugCmds -> Mod CommandFields DebugCmds forall a. String -> ParserInfo a -> Mod CommandFields a commandWithMetavar String "view" (ParserInfo DebugCmds -> Mod CommandFields DebugCmds) -> ParserInfo DebugCmds -> Mod CommandFields DebugCmds forall a b. (a -> b) -> a -> b $ Parser DebugCmds -> InfoMod DebugCmds -> ParserInfo DebugCmds forall a. Parser a -> InfoMod a -> ParserInfo a Opt.info Parser DebugCmds pTransactionView (InfoMod DebugCmds -> ParserInfo DebugCmds) -> InfoMod DebugCmds -> ParserInfo DebugCmds forall a b. (a -> b) -> a -> b $ String -> InfoMod DebugCmds forall a. String -> InfoMod a Opt.progDesc String "Print a transaction." ] ) (String -> InfoMod DebugCmds forall a. String -> InfoMod a Opt.progDesc String "Transaction commands") ] where pLogEpochStateCmdArgs :: Parser DebugCmds pLogEpochStateCmdArgs :: Parser DebugCmds pLogEpochStateCmdArgs = (LogEpochStateCmdArgs -> DebugCmds) -> Parser LogEpochStateCmdArgs -> Parser DebugCmds forall a b. (a -> b) -> Parser a -> Parser b forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap LogEpochStateCmdArgs -> DebugCmds DebugLogEpochStateCmd (Parser LogEpochStateCmdArgs -> Parser DebugCmds) -> Parser LogEpochStateCmdArgs -> Parser DebugCmds forall a b. (a -> b) -> a -> b $ SocketPath -> NodeConfigFile 'In -> File Configuration 'Out -> LogEpochStateCmdArgs LogEpochStateCmdArgs (SocketPath -> NodeConfigFile 'In -> File Configuration 'Out -> LogEpochStateCmdArgs) -> Parser SocketPath -> Parser (NodeConfigFile 'In -> File Configuration 'Out -> LogEpochStateCmdArgs) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> EnvCli -> Parser SocketPath pSocketPath EnvCli envCli Parser (NodeConfigFile 'In -> File Configuration 'Out -> LogEpochStateCmdArgs) -> Parser (NodeConfigFile 'In) -> Parser (File Configuration 'Out -> LogEpochStateCmdArgs) forall a b. Parser (a -> b) -> Parser a -> Parser b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Parser (NodeConfigFile 'In) pNodeConfigurationFileIn Parser (File Configuration 'Out -> LogEpochStateCmdArgs) -> Parser (File Configuration 'Out) -> Parser LogEpochStateCmdArgs forall a b. Parser (a -> b) -> Parser a -> Parser b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> String -> String -> Parser (File Configuration 'Out) forall a. String -> String -> Parser (File a 'Out) pFileOutDirection String "out-file" String "Output filepath of the log file. The log file format is line delimited JSON." pCheckNodeConfigurationCmdArgs :: Parser DebugCmds pCheckNodeConfigurationCmdArgs :: Parser DebugCmds pCheckNodeConfigurationCmdArgs = (CheckNodeConfigCmdArgs -> DebugCmds) -> Parser CheckNodeConfigCmdArgs -> Parser DebugCmds forall a b. (a -> b) -> Parser a -> Parser b forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap CheckNodeConfigCmdArgs -> DebugCmds DebugCheckNodeConfigurationCmd (Parser CheckNodeConfigCmdArgs -> Parser DebugCmds) -> Parser CheckNodeConfigCmdArgs -> Parser DebugCmds forall a b. (a -> b) -> a -> b $ NodeConfigFile 'In -> CheckNodeConfigCmdArgs CheckNodeConfigCmdArgs (NodeConfigFile 'In -> CheckNodeConfigCmdArgs) -> Parser (NodeConfigFile 'In) -> Parser CheckNodeConfigCmdArgs forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Parser (NodeConfigFile 'In) pNodeConfigurationFileIn pTransactionView :: Parser DebugCmds pTransactionView :: Parser DebugCmds pTransactionView = (TransactionViewCmdArgs -> DebugCmds) -> Parser TransactionViewCmdArgs -> Parser DebugCmds forall a b. (a -> b) -> Parser a -> Parser b forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap TransactionViewCmdArgs -> DebugCmds DebugTransactionViewCmd (Parser TransactionViewCmdArgs -> Parser DebugCmds) -> Parser TransactionViewCmdArgs -> Parser DebugCmds forall a b. (a -> b) -> a -> b $ Vary '[FormatJson, FormatYaml] -> Maybe (File () 'Out) -> InputTxBodyOrTxFile -> TransactionViewCmdArgs TransactionViewCmdArgs (Vary '[FormatJson, FormatYaml] -> Maybe (File () 'Out) -> InputTxBodyOrTxFile -> TransactionViewCmdArgs) -> Parser (Vary '[FormatJson, FormatYaml]) -> Parser (Maybe (File () 'Out) -> InputTxBodyOrTxFile -> TransactionViewCmdArgs) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> String -> [Flag (Vary '[FormatJson, FormatYaml])] -> Parser (Vary '[FormatJson, FormatYaml]) forall (fs :: [*]). String -> [Flag (Vary fs)] -> Parser (Vary fs) pFormatFlags String "transaction view output" [ Flag (Vary '[FormatJson, FormatYaml]) forall (fs :: [*]). (FormatJson :| fs) => Flag (Vary fs) flagFormatJson Flag (Vary '[FormatJson, FormatYaml]) -> (Flag (Vary '[FormatJson, FormatYaml]) -> Flag (Vary '[FormatJson, FormatYaml])) -> Flag (Vary '[FormatJson, FormatYaml]) forall a b. a -> (a -> b) -> b & Flag (Vary '[FormatJson, FormatYaml]) -> Flag (Vary '[FormatJson, FormatYaml]) forall a. Flag a -> Flag a setDefault , Flag (Vary '[FormatJson, FormatYaml]) forall (fs :: [*]). (FormatYaml :| fs) => Flag (Vary fs) flagFormatYaml ] Parser (Maybe (File () 'Out) -> InputTxBodyOrTxFile -> TransactionViewCmdArgs) -> Parser (Maybe (File () 'Out)) -> Parser (InputTxBodyOrTxFile -> TransactionViewCmdArgs) forall a b. Parser (a -> b) -> Parser a -> Parser b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Parser (Maybe (File () 'Out)) forall content. Parser (Maybe (File content 'Out)) pMaybeOutputFile Parser (InputTxBodyOrTxFile -> TransactionViewCmdArgs) -> Parser InputTxBodyOrTxFile -> Parser TransactionViewCmdArgs forall a b. Parser (a -> b) -> Parser a -> Parser b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Parser InputTxBodyOrTxFile pInputTxOrTxBodyFile pNodeConfigurationFileIn :: Parser (NodeConfigFile In) pNodeConfigurationFileIn :: Parser (NodeConfigFile 'In) pNodeConfigurationFileIn = String -> NodeConfigFile 'In forall content (direction :: FileDirection). String -> File content direction File (String -> NodeConfigFile 'In) -> Parser String -> Parser (NodeConfigFile 'In) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> String -> String -> Parser String parseFilePath String "node-configuration-file" String "Input filepath of the node configuration file."