Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Commit f1157f0

Browse files
authored
[GH-233] Add NTP, Update, SSC, TXP, DLG specific configuration options using CLI (#237)
* [GH-235] Fixing nested configuration problems. * [GH-235] Fixing review suggestions, cleaner solution. * [GH-233] Add NTP, Update, SSC, TXP, DLG specific configuration options using CLI.
1 parent 539171e commit f1157f0

File tree

6 files changed

+586
-271
lines changed

6 files changed

+586
-271
lines changed

app/Main.hs

Lines changed: 12 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,8 @@ import Cardano.Shell.Features.Logging (LoggingCLIArguments,
1111
import Cardano.Shell.Features.Networking (createNetworkingFeature)
1212

1313
import Cardano.Shell.Configuration.Lib (finaliseCardanoConfiguration)
14-
import Cardano.Shell.Constants.CLI (configBlockCLIParser,
15-
configCoreCLIParser,
16-
configWalletCLIParser)
17-
import Cardano.Shell.Constants.PartialTypes (PartialBlock (..), PartialCardanoConfiguration (..),
18-
PartialCore (..),
19-
PartialWallet (..))
14+
import Cardano.Shell.Constants.CLI (configCardanoConfigurationCLIParser)
15+
import Cardano.Shell.Constants.PartialTypes (PartialCardanoConfiguration (..))
2016
import Cardano.Shell.Lib
2117
import Cardano.Shell.Presets (mainnetConfiguration)
2218
import Cardano.Shell.Types
@@ -26,11 +22,7 @@ import Options.Applicative
2622

2723
-- | The product type of all command line arguments.
2824
-- All here being - from all the features.
29-
data CLIArguments = CLIArguments
30-
!LoggingCLIArguments
31-
!PartialWallet
32-
!PartialBlock
33-
!PartialCore
25+
data CLIArguments = CLIArguments !LoggingCLIArguments !PartialCardanoConfiguration
3426

3527
main :: IO ()
3628
main = do
@@ -94,49 +86,23 @@ initializeAllFeatures :: PartialCardanoConfiguration -> CardanoEnvironment -> IO
9486
initializeAllFeatures partialConfig cardanoEnvironment = do
9587

9688
-- Here we parse the __CLI__ arguments for the actual application.
97-
CLIArguments loggingCLIArguments walletCLI blockCLI coreCLI <- execParser parserWithInfo
89+
CLIArguments loggingCLIArguments cardanoConfigurationCLI <- execParser parserWithInfo
9890

99-
let configCore = pccCore partialConfig
100-
let configBlock = pccBlock partialConfig
101-
let configWallet = pccWallet partialConfig
102-
103-
let pccCore' = configCore <> coreCLI
104-
let pccBlock' = configBlock <> blockCLI
105-
let pccWallet' = configWallet <> walletCLI
106-
107-
putTextLn "************************************************"
108-
putTextLn "CORE"
109-
putTextLn "************************************************"
110-
putTextLn $ show configCore
111-
putTextLn "------------------------------------------------"
112-
putTextLn $ show coreCLI
113-
putTextLn "------------------------------------------------"
114-
putTextLn $ show pccCore'
91+
let cardanoConfiguration' = partialConfig <> cardanoConfigurationCLI
11592

11693
putTextLn "************************************************"
117-
putTextLn "BLOCK"
94+
putTextLn "Cardano configurationn"
11895
putTextLn "************************************************"
119-
putTextLn $ show configBlock
120-
putTextLn "------------------------------------------------"
121-
putTextLn $ show blockCLI
96+
putTextLn $ show partialConfig
12297
putTextLn "------------------------------------------------"
123-
putTextLn $ show pccBlock'
124-
125-
putTextLn "************************************************"
126-
putTextLn "WALLET"
127-
putTextLn "************************************************"
128-
putTextLn $ show configWallet
98+
putTextLn $ show cardanoConfigurationCLI
12999
putTextLn "------------------------------------------------"
130-
putTextLn $ show walletCLI
100+
putTextLn $ show cardanoConfiguration'
131101
putTextLn "------------------------------------------------"
132-
putTextLn $ show pccWallet'
133102

103+
-- Finalize the configuration and if something is missing, just throw error.
134104
finalConfig <- either (throwIO . ConfigurationError) pure $
135-
finaliseCardanoConfiguration $ partialConfig
136-
{ pccCore = pccCore'
137-
, pccBlock = pccBlock'
138-
, pccWallet = pccWallet'
139-
}
105+
finaliseCardanoConfiguration cardanoConfiguration'
140106

141107
-- Here we initialize all the features
142108
(loggingLayer, loggingFeature) <- createLoggingFeature cardanoEnvironment finalConfig loggingCLIArguments
@@ -164,7 +130,5 @@ initializeAllFeatures partialConfig cardanoEnvironment = do
164130
commandLineParser :: Parser CLIArguments
165131
commandLineParser = CLIArguments
166132
<$> loggingParser
167-
<*> configWalletCLIParser
168-
<*> configBlockCLIParser
169-
<*> configCoreCLIParser
133+
<*> configCardanoConfigurationCLIParser
170134

0 commit comments

Comments
 (0)