Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tbidne committed Mar 7, 2024
1 parent 5c7c566 commit 40eceb1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Shrun/Configuration/Data/CmdLogging.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import Shrun.Data.Truncation
)
import Shrun.Prelude

-- Cmd log line truncation is truly optional, the default being none.
type CmdLogLineTruncF :: ConfigPhase -> Type
type family CmdLogLineTruncF p where
CmdLogLineTruncF ConfigPhaseArgs = WithDisable (Maybe LineTruncation)
Expand Down
1 change: 1 addition & 0 deletions src/Shrun/Configuration/Data/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ data CoreConfigP p = MkCoreConfigP
-- | How often to poll commands for logs, in microseconds.
pollInterval :: ConfigPhaseF p PollInterval,
-- | Determines the max log size we read from commands in one go.
-- Note this is not on cmdLogging or fileLogging since it affects both.
cmdLogSize :: ConfigPhaseF p (Bytes B Natural),
-- | How to format the timer.
timerFormat :: ConfigPhaseF p TimerFormat,
Expand Down
19 changes: 19 additions & 0 deletions src/Shrun/Configuration/Data/FileLogging.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@ import Shrun.Data.FileSizeMode (FileSizeMode, defaultFileSizeMode)
import Shrun.Data.StripControl (StripControl (StripControlAll))
import Shrun.Prelude

-- NOTE: [Args vs. Toml mandatory fields]
--
-- Some fields are mandatory e.g. FileLogging's path if we are actually
-- doing file logging. The latter is determined by the FileLoggingP itself
-- being Just (cf. Nothing), thus the path itself is mandatory on Toml and
-- Merged.
--
-- So why is it optional on Args? Because Args' FileLoggingP is _always_
-- present, unlike Toml and Merged's Maybe. We need this behavior because the
-- former's fields can be used to override toml fields, even if file-logging is
-- not specified on the CLI.
--
-- For example, 'shrun --file-log-mode write cmd' _should_ overwrite toml's
-- file-log.mode even though we did not specify --file-log. Therefore Args'
-- FileLoggingP always needs to be present hence all its field must be
-- optional, even when some are mandatory on Merged.

-- File logging's path is only optional for the Args. For Toml and merged,
-- it must be present if file logging is active.
type FileLogPathF :: ConfigPhase -> Type
type family FileLogPathF p where
FileLogPathF ConfigPhaseArgs = WithDisable (Maybe FilePathDefault)
Expand Down
4 changes: 4 additions & 0 deletions src/Shrun/Configuration/Data/Notify.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ import Shrun.Notify.Types
)
import Shrun.Prelude

-- Notify action is mandatory if we are running notifications.
--
-- See NOTE: [Args vs. Toml mandatory fields]

type NotifyActionF :: ConfigPhase -> Type
type family NotifyActionF p where
NotifyActionF ConfigPhaseArgs = WithDisable (Maybe NotifyAction)
Expand Down

0 comments on commit 40eceb1

Please sign in to comment.