@@ -20,15 +20,32 @@ import Core.Options
20
20
, walletOption
21
21
)
22
22
import Core.Types.MPFS (mpfsClientOption )
23
+ import Core.Types.Mnemonics.Options (queryConsole )
24
+ import Data.ByteString.Char8 qualified as B
25
+ import Data.Functor (($>) )
26
+ import Data.Text (Text )
27
+ import Data.Text qualified as T
28
+ import Data.Text.Encoding qualified as T
23
29
import Data.Version (Version )
24
30
import Facts (FactsSelection (.. ), TestRunSelection (.. ))
31
+ import GitHub (Auth (.. ))
25
32
import Lib.Box (Box (.. ), fmapBox )
26
33
import MPFS.API (mpfsClient )
27
34
import OptEnvConf
28
35
( Parser
36
+ , auto
29
37
, command
30
38
, commands
39
+ , env
40
+ , help
41
+ , long
42
+ , mapIO
43
+ , metavar
44
+ , option
45
+ , reader
31
46
, runParser
47
+ , setting
48
+ , str
32
49
, (<|>)
33
50
)
34
51
import Oracle.Options (oracleCommandParser )
@@ -40,20 +57,47 @@ newtype Options a = Options
40
57
{ optionsCommand :: Command a
41
58
}
42
59
60
+ githubAuthOption :: Parser Auth
61
+ githubAuthOption =
62
+ fmap OAuth
63
+ $ mapIO id
64
+ $ setting
65
+ [ help " Prompt for the passphrase for the encrypted mnemonics"
66
+ , env " ANTI_INTERACTIVE_PASSWORD"
67
+ , metavar " NONE"
68
+ , long " ask-passphrase"
69
+ , option
70
+ , reader
71
+ $ str @ String
72
+ $> ( T. encodeUtf8
73
+ <$> queryConsole " Enter your GitHub personal access token: "
74
+ )
75
+ ]
76
+ <|> setting
77
+ [ env " GITHUB_PERSONAL_ACCESS_TOKEN"
78
+ , metavar " PASSPHRASE"
79
+ , help
80
+ " A GitHub personal access token with access to public repositories"
81
+ , reader $ fmap (pure . B. pack) str
82
+ ]
83
+
43
84
commandParser :: Parser (Box Command )
44
85
commandParser =
45
86
commands
46
87
[ command " oracle" " Manage oracle operations"
47
- $ (\ c -> fmapBox (OracleCommand c))
48
- <$> mpfsClientOption
88
+ $ (\ a c -> fmapBox (OracleCommand a c))
89
+ <$> githubAuthOption
90
+ <*> mpfsClientOption
49
91
<*> oracleCommandParser
50
92
, command " requester" " Manage requester operations"
51
- $ (\ c -> fmapBox (RequesterCommand c))
52
- <$> mpfsClientOption
93
+ $ (\ a c -> fmapBox (RequesterCommand a c))
94
+ <$> githubAuthOption
95
+ <*> mpfsClientOption
53
96
<*> requesterCommandParser
54
97
, command " agent" " Manage agent operations"
55
- $ (\ c -> fmapBox (AgentCommand c))
56
- <$> mpfsClientOption
98
+ $ (\ a c -> fmapBox (AgentCommand a c))
99
+ <$> githubAuthOption
100
+ <*> mpfsClientOption
57
101
<*> agentCommandParser
58
102
, command " wallet" " Manage wallet operations"
59
103
$ fmapBox Wallet <$> walletCommandParser
@@ -67,7 +111,10 @@ commandParser =
67
111
<*> tokenIdOption
68
112
<*> factsSelectionParser
69
113
, command " token" " Get the token content"
70
- $ fmap Box . GetToken <$> mpfsClientOption <*> tokenIdOption
114
+ $ (\ a -> fmap Box . GetToken a)
115
+ <$> githubAuthOption
116
+ <*> mpfsClientOption
117
+ <*> tokenIdOption
71
118
]
72
119
73
120
factsSelectionParser :: Parser (Box FactsSelection )
0 commit comments