{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Cardano.CLI.Options.Debug
( parseDebugCmds
)
where
import Cardano.Api.Shelley hiding (QueryInShelleyBasedEra (..))
import Cardano.CLI.Commands.Debug
import Cardano.CLI.Commands.Debug.CheckNodeConfiguration
import Cardano.CLI.Commands.Debug.LogEpochState
import Cardano.CLI.Commands.Debug.TransactionView
import Cardano.CLI.Environment
import Cardano.CLI.EraBased.Options.Common
import Cardano.CLI.Parser
import Data.Foldable
import Options.Applicative hiding (help, str)
import qualified Options.Applicative 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 -> Mod CommandFields DebugCmds
forall a. String -> Mod CommandFields a
Opt.commandGroup 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
[ String -> ParserInfo DebugCmds -> Parser DebugCmds
forall a. String -> ParserInfo a -> Parser a
subParser String
"log-epoch-state" (ParserInfo DebugCmds -> Parser DebugCmds)
-> ParserInfo DebugCmds -> Parser 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."
]
, String -> ParserInfo DebugCmds -> Parser DebugCmds
forall a. String -> ParserInfo a -> Parser a
subParser String
"check-node-configuration" (ParserInfo DebugCmds -> Parser DebugCmds)
-> ParserInfo DebugCmds -> Parser 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."
, String -> ParserInfo DebugCmds -> Parser DebugCmds
forall a. String -> ParserInfo a -> Parser a
subParser String
"transaction" (ParserInfo DebugCmds -> Parser DebugCmds)
-> ParserInfo DebugCmds -> Parser 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
[ String -> ParserInfo DebugCmds -> Parser DebugCmds
forall a. String -> ParserInfo a -> Parser a
subParser String
"view" (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
$
ViewOutputFormat
-> Maybe (File () 'Out)
-> InputTxBodyOrTxFile
-> TransactionViewCmdArgs
TransactionViewCmdArgs
(ViewOutputFormat
-> Maybe (File () 'Out)
-> InputTxBodyOrTxFile
-> TransactionViewCmdArgs)
-> Parser ViewOutputFormat
-> Parser
(Maybe (File () 'Out)
-> InputTxBodyOrTxFile -> TransactionViewCmdArgs)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ViewOutputFormat
pTxViewOutputFormat
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."