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

[GH-233] Add NTP, Update, SSC, TXP, DLG specific configuration options using CLI #237

Merged
merged 4 commits into from
Jul 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 12 additions & 48 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@ import Cardano.Shell.Features.Logging (LoggingCLIArguments,
import Cardano.Shell.Features.Networking (createNetworkingFeature)

import Cardano.Shell.Configuration.Lib (finaliseCardanoConfiguration)
import Cardano.Shell.Constants.CLI (configBlockCLIParser,
configCoreCLIParser,
configWalletCLIParser)
import Cardano.Shell.Constants.PartialTypes (PartialBlock (..), PartialCardanoConfiguration (..),
PartialCore (..),
PartialWallet (..))
import Cardano.Shell.Constants.CLI (configCardanoConfigurationCLIParser)
import Cardano.Shell.Constants.PartialTypes (PartialCardanoConfiguration (..))
import Cardano.Shell.Lib
import Cardano.Shell.Presets (mainnetConfiguration)
import Cardano.Shell.Types
Expand All @@ -26,11 +22,7 @@ import Options.Applicative

-- | The product type of all command line arguments.
-- All here being - from all the features.
data CLIArguments = CLIArguments
!LoggingCLIArguments
!PartialWallet
!PartialBlock
!PartialCore
data CLIArguments = CLIArguments !LoggingCLIArguments !PartialCardanoConfiguration

main :: IO ()
main = do
Expand Down Expand Up @@ -94,49 +86,23 @@ initializeAllFeatures :: PartialCardanoConfiguration -> CardanoEnvironment -> IO
initializeAllFeatures partialConfig cardanoEnvironment = do

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

let configCore = pccCore partialConfig
let configBlock = pccBlock partialConfig
let configWallet = pccWallet partialConfig

let pccCore' = configCore <> coreCLI
let pccBlock' = configBlock <> blockCLI
let pccWallet' = configWallet <> walletCLI

putTextLn "************************************************"
putTextLn "CORE"
putTextLn "************************************************"
putTextLn $ show configCore
putTextLn "------------------------------------------------"
putTextLn $ show coreCLI
putTextLn "------------------------------------------------"
putTextLn $ show pccCore'
let cardanoConfiguration' = partialConfig <> cardanoConfigurationCLI

putTextLn "************************************************"
putTextLn "BLOCK"
putTextLn "Cardano configurationn"
putTextLn "************************************************"
putTextLn $ show configBlock
putTextLn "------------------------------------------------"
putTextLn $ show blockCLI
putTextLn $ show partialConfig
putTextLn "------------------------------------------------"
putTextLn $ show pccBlock'

putTextLn "************************************************"
putTextLn "WALLET"
putTextLn "************************************************"
putTextLn $ show configWallet
putTextLn $ show cardanoConfigurationCLI
putTextLn "------------------------------------------------"
putTextLn $ show walletCLI
putTextLn $ show cardanoConfiguration'
putTextLn "------------------------------------------------"
putTextLn $ show pccWallet'

-- Finalize the configuration and if something is missing, just throw error.
finalConfig <- either (throwIO . ConfigurationError) pure $
finaliseCardanoConfiguration $ partialConfig
{ pccCore = pccCore'
, pccBlock = pccBlock'
, pccWallet = pccWallet'
}
finaliseCardanoConfiguration cardanoConfiguration'

-- Here we initialize all the features
(loggingLayer, loggingFeature) <- createLoggingFeature cardanoEnvironment finalConfig loggingCLIArguments
Expand Down Expand Up @@ -164,7 +130,5 @@ initializeAllFeatures partialConfig cardanoEnvironment = do
commandLineParser :: Parser CLIArguments
commandLineParser = CLIArguments
<$> loggingParser
<*> configWalletCLIParser
<*> configBlockCLIParser
<*> configCoreCLIParser
<*> configCardanoConfigurationCLIParser

Loading