@@ -12,10 +12,12 @@ module Options
12
12
, optionsParser
13
13
, parseArgs
14
14
, githubAuthOption
15
+ , secretsFileOption
15
16
) where
16
17
17
18
import Cli (Command (.. ))
18
19
import Control.Applicative (optional )
20
+ import Control.Arrow (left )
19
21
import Core.Options
20
22
( outputReferenceParser
21
23
, tokenIdOption
@@ -34,11 +36,13 @@ import Lib.Options.Secrets (secretsParser)
34
36
import OptEnvConf
35
37
( Alternative (.. )
36
38
, Parser
39
+ , checkEither
37
40
, command
38
41
, commands
39
42
, env
40
43
, help
41
44
, long
45
+ , mapIO
42
46
, metavar
43
47
, option
44
48
, reader
@@ -47,9 +51,20 @@ import OptEnvConf
47
51
, str
48
52
, switch
49
53
, value
54
+ , withYamlConfig
50
55
, (<|>)
51
56
)
52
57
import Oracle.Options (oracleCommandParser )
58
+ import Path
59
+ ( Abs
60
+ , File
61
+ , Path
62
+ , SomeBase (Abs , Rel )
63
+ , parseAbsFile
64
+ , parseSomeFile
65
+ , toFilePath
66
+ )
67
+ import System.Directory (makeAbsolute )
53
68
import User.Agent.Options (agentCommandParser , testRunIdOption )
54
69
import User.Agent.Types (TestRunId )
55
70
import User.Requester.Options
@@ -221,11 +236,28 @@ parseArgs version =
221
236
runParser
222
237
version
223
238
intro
224
- optionsParser
239
+ $ withYamlConfig secretsFileOption optionsParser
225
240
226
241
retractRequestOptions :: Parser (Box Command )
227
242
retractRequestOptions =
228
243
fmap (fmap Box ) . RetractRequest
229
244
<$> mpfsClientOption
230
245
<*> walletOption
231
246
<*> outputReferenceParser
247
+
248
+ secretsFileOption :: Parser (Maybe (Path Abs File ))
249
+ secretsFileOption =
250
+ optional
251
+ $ parsePath
252
+ $ setting
253
+ [ long " secrets-file"
254
+ , metavar " FILEPATH"
255
+ , help " The file path to a YAML file containing secrets"
256
+ , reader str
257
+ , option
258
+ , env " ANTI_SECRETS_FILE"
259
+ ]
260
+ where
261
+ parsePath = mapIO absolutize . checkEither (left show . parseSomeFile)
262
+ absolutize (Abs fp) = pure fp
263
+ absolutize (Rel fp) = makeAbsolute (toFilePath fp) >>= parseAbsFile
0 commit comments