@@ -27,8 +27,11 @@ import Data.Foldable
2727import Data.Maybe (fromMaybe )
2828import Data.Monoid (Last (.. ))
2929import Data.Text (Text )
30- import Data.Word (Word32 )
31- import Options.Applicative hiding (str )
30+ import qualified Data.Text as Text
31+ import Data.Word (Word16 , Word32 )
32+ import Options.Applicative hiding (str , switch )
33+ -- Don't use switch. It will not allow to set an option in a configuration
34+ -- file. See `parseStartAsNonProducingNode` and `parseValidateDB`.
3235import qualified Options.Applicative as Opt
3336import qualified Options.Applicative.Help as OptI
3437import System.Posix.Types (Fd (.. ))
@@ -60,7 +63,7 @@ nodeRunParser = do
6063 shelleyVRFFile <- optional parseVrfKeyFilePath
6164 shelleyCertFile <- optional parseOperationalCertFilePath
6265 shelleyBulkCredsFile <- optional parseBulkCredsFilePath
63- startAsNonProducingNode <- lastOption parseStartAsNonProducingNode
66+ startAsNonProducingNode <- Last <$> parseStartAsNonProducingNode
6467
6568 -- Node Address
6669 nIPv4Address <- lastOption parseHostIPv4Addr
@@ -266,9 +269,13 @@ parseImmutableDbPath = strOption $
266269 ]
267270
268271
272+ -- | This parser will always override configuration option, even if the
273+ -- `--validate-db` is not present. This is fine for `--validate-db` switch,
274+ -- but might not be for something else. See `parseStartAsNonProducingNode` for
275+ -- an alternative solution.
269276parseValidateDB :: Parser Bool
270277parseValidateDB =
271- switch (
278+ Opt. switch (
272279 long " validate-db"
273280 <> help " Validate all on-disk database files"
274281 )
@@ -353,9 +360,12 @@ parseVrfKeyFilePath =
353360 <> completer (bashCompleter " file" )
354361 )
355362
356- parseStartAsNonProducingNode :: Parser Bool
363+ -- | A parser which returns `Nothing` or `Just True`; the default value is set
364+ -- in `defaultPartialNodeConfiguration`. This allows to set this option either
365+ -- in the configuration file or as command line flag.
366+ parseStartAsNonProducingNode :: Parser (Maybe Bool )
357367parseStartAsNonProducingNode =
358- switch $ mconcat
368+ flag Nothing ( Just True ) $ mconcat
359369 [ long " non-producing-node"
360370 , help $ mconcat
361371 [ " Start the node as a non block producing node even if "
0 commit comments