Skip to content

Commit 2880839

Browse files
committed
[cli] feat: add verbosity switch to anti-agent
1 parent 0f6ea04 commit 2880839

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

cli/src/User/Agent/Process.hs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module User.Agent.Process
2121
import Cli (Command (..), TokenInfoFailure, WithValidation (..), cmd)
2222
import Control.Applicative (Alternative (..), optional)
2323
import Control.Concurrent (threadDelay)
24-
import Control.Monad (forever)
24+
import Control.Monad (forever, when)
2525
import Control.Monad.IO.Class (MonadIO (..))
2626
import Control.Monad.Trans.Except (runExceptT, throwE)
2727
import Core.Options (tokenIdOption, walletOption)
@@ -52,6 +52,8 @@ import OptEnvConf
5252
, setting
5353
, short
5454
, strOption
55+
, switch
56+
, value
5557
, withYamlConfig
5658
)
5759
import Options (githubAuthOption, secretsFileOption)
@@ -133,6 +135,7 @@ data ProcessOptions = ProcessOptions
133135
, poTrustedCreators :: [Username]
134136
, poRegistry :: Registry
135137
, poAntithesisAuth :: AntithesisAuth
138+
, poVerbose :: Bool
136139
}
137140

138141
processOptionsParser :: Parser ProcessOptions
@@ -149,6 +152,17 @@ processOptionsParser =
149152
<*> creatorsOption
150153
<*> registryOption
151154
<*> antithesisAuthOption
155+
<*> verboseOption
156+
157+
verboseOption :: Parser Bool
158+
verboseOption =
159+
setting
160+
[ long "verbose"
161+
, help "Enable verbose logging."
162+
, metavar "VERBOSE"
163+
, switch True
164+
, value False
165+
]
152166

153167
creatorsOption :: Parser [Username]
154168
creatorsOption =
@@ -178,7 +192,7 @@ creatorsOption =
178192
agentProcess
179193
:: ProcessOptions
180194
-> IO ()
181-
agentProcess opts@ProcessOptions{poPollIntervalSeconds} = do
195+
agentProcess opts@ProcessOptions{poPollIntervalSeconds, poVerbose} = do
182196
putStrLn "Starting agent process service..."
183197
forever $ runExceptT $ do
184198
results <- liftIO $ pollEmails opts
@@ -231,7 +245,7 @@ agentProcess opts@ProcessOptions{poPollIntervalSeconds} = do
231245
++ trId
232246
++ " in transaction "
233247
++ show txHash
234-
Just (Right _) -> do
248+
Just (Right _) -> when poVerbose $ do
235249
loggin
236250
$ "Test-run "
237251
++ trId

0 commit comments

Comments
 (0)