|
2 | 2 |
|
3 | 3 | module Cardano.TxSubmit.CLI.Parsers
|
4 | 4 | ( opts
|
5 |
| - , pTxSubmitNodeParams |
| 5 | + , pTxSubmit |
6 | 6 | , pConfigFile
|
7 | 7 | , pSocketPath
|
8 |
| - ) where |
| 8 | + ) |
| 9 | +where |
9 | 10 |
|
10 | 11 | import Cardano.Api (File (..), SocketPath)
|
11 | 12 |
|
12 | 13 | import Cardano.CLI.Environment (EnvCli (..))
|
13 | 14 | import Cardano.CLI.EraBased.Common.Option
|
14 |
| -import Cardano.TxSubmit.CLI.Types (ConfigFile (..), TxSubmitNodeParams (..)) |
| 15 | +import Cardano.TxSubmit.CLI.Types (ConfigFile (..), TxSubmitCommand (..), |
| 16 | + TxSubmitNodeParams (..)) |
15 | 17 | import Cardano.TxSubmit.Rest.Parsers (pWebserverConfig)
|
16 | 18 |
|
17 |
| -import Control.Applicative ((<**>)) |
| 19 | +import Control.Applicative |
18 | 20 | import Options.Applicative (Parser, ParserInfo)
|
19 | 21 | import qualified Options.Applicative as Opt
|
20 | 22 |
|
21 |
| -opts :: EnvCli -> ParserInfo TxSubmitNodeParams |
| 23 | +opts :: EnvCli -> ParserInfo TxSubmitCommand |
22 | 24 | opts envCli =
|
23 |
| - Opt.info (pTxSubmitNodeParams envCli <**> Opt.helper) $ mconcat |
24 |
| - [ Opt.fullDesc |
25 |
| - , Opt.progDesc "Cardano transaction submission web API." |
| 25 | + Opt.info (pTxSubmit envCli <**> Opt.helper) $ |
| 26 | + mconcat |
| 27 | + [ Opt.fullDesc |
| 28 | + , Opt.progDesc "Cardano transaction submission web API." |
| 29 | + ] |
| 30 | + |
| 31 | +pTxSubmit :: EnvCli -> Parser TxSubmitCommand |
| 32 | +pTxSubmit envCli = |
| 33 | + asum |
| 34 | + [ TxSubmitRun |
| 35 | + <$> ( TxSubmitNodeParams |
| 36 | + <$> pConfigFile |
| 37 | + <*> pConsensusModeParams |
| 38 | + <*> pNetworkId envCli |
| 39 | + <*> pSocketPath' |
| 40 | + <*> pWebserverConfig 8090 |
| 41 | + <*> pMetricsPort 8081 |
| 42 | + ) |
| 43 | + , pVersion |
26 | 44 | ]
|
27 | 45 |
|
28 |
| -pTxSubmitNodeParams :: EnvCli -> Parser TxSubmitNodeParams |
29 |
| -pTxSubmitNodeParams envCli = TxSubmitNodeParams |
30 |
| - <$> pConfigFile |
31 |
| - <*> pConsensusModeParams |
32 |
| - <*> pNetworkId envCli |
33 |
| - <*> pSocketPath' |
34 |
| - <*> pWebserverConfig 8090 |
35 |
| - <*> pMetricsPort 8081 |
| 46 | +pVersion :: Parser TxSubmitCommand |
| 47 | +pVersion = |
| 48 | + Opt.flag' |
| 49 | + TxSubmitVersion |
| 50 | + ( Opt.long "version" |
| 51 | + <> Opt.help "Show the cardano-submit-api version" |
| 52 | + <> Opt.hidden |
| 53 | + ) |
36 | 54 |
|
37 | 55 | pConfigFile :: Parser ConfigFile
|
38 |
| -pConfigFile = ConfigFile <$> Opt.strOption |
39 |
| - ( Opt.long "config" |
40 |
| - <> Opt.help "Path to the tx-submit web API configuration file" |
41 |
| - <> Opt.completer (Opt.bashCompleter "file") |
42 |
| - <> Opt.metavar "FILEPATH" |
43 |
| - ) |
| 56 | +pConfigFile = |
| 57 | + ConfigFile |
| 58 | + <$> Opt.strOption |
| 59 | + ( Opt.long "config" |
| 60 | + <> Opt.help "Path to the tx-submit web API configuration file" |
| 61 | + <> Opt.completer (Opt.bashCompleter "file") |
| 62 | + <> Opt.metavar "FILEPATH" |
| 63 | + ) |
44 | 64 |
|
45 | 65 | pSocketPath' :: Parser SocketPath
|
46 | 66 | pSocketPath' =
|
47 |
| - fmap File $ Opt.strOption $ mconcat |
48 |
| - [ Opt.long "socket-path" |
49 |
| - , Opt.help "Path to a cardano-node socket" |
50 |
| - , Opt.completer (Opt.bashCompleter "file") |
51 |
| - , Opt.metavar "FILEPATH" |
52 |
| - ] |
| 67 | + fmap File $ |
| 68 | + Opt.strOption $ |
| 69 | + mconcat |
| 70 | + [ Opt.long "socket-path" |
| 71 | + , Opt.help "Path to a cardano-node socket" |
| 72 | + , Opt.completer (Opt.bashCompleter "file") |
| 73 | + , Opt.metavar "FILEPATH" |
| 74 | + ] |
53 | 75 |
|
54 | 76 | pMetricsPort :: Int -> Parser Int
|
55 |
| -pMetricsPort defaultValue = Opt.option Opt.auto |
56 |
| - ( Opt.long "metrics-port" |
57 |
| - <> Opt.help ("Port for exposing metrics. If unavailable, the next free port is used. If no port can be allocated, " |
58 |
| - <> "the transaction submission API starts without metrics endpoint.") |
59 |
| - <> Opt.metavar "PORT" |
60 |
| - <> Opt.value defaultValue |
61 |
| - <> Opt.showDefault |
62 |
| - ) |
| 77 | +pMetricsPort defaultValue = |
| 78 | + Opt.option |
| 79 | + Opt.auto |
| 80 | + ( Opt.long "metrics-port" |
| 81 | + <> Opt.help |
| 82 | + ( "Port for exposing metrics. If unavailable, the next free port is used. If no port can be allocated, " |
| 83 | + <> "the transaction submission API starts without metrics endpoint." |
| 84 | + ) |
| 85 | + <> Opt.metavar "PORT" |
| 86 | + <> Opt.value defaultValue |
| 87 | + <> Opt.showDefault |
| 88 | + ) |
0 commit comments