Skip to content

Commit a32bc45

Browse files
committed
[cli] Add config and white-listed facts selectors for facts command
1 parent 539d9e4 commit a32bc45

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

cli/src/Facts.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ where
88
import Core.Types.Basic (TokenId)
99
import Core.Types.Fact (Fact (..), parseFacts)
1010
import MPFS.API (MPFS, mpfsGetTokenFacts)
11+
import Oracle.Config.Types (Config, ConfigKey)
1112
import Text.JSON.Canonical
13+
import User.Agent.Types (WhiteListKey)
1214
import User.Types
1315
( Phase (..)
1416
, RegisterUserKey
@@ -28,7 +30,10 @@ data FactsSelection a where
2830
UserFacts :: FactsSelection [Fact RegisterUserKey ()]
2931
RoleFacts :: FactsSelection [Fact RegisterUserKey ()]
3032
TestRunFacts :: TestRunSelection a -> FactsSelection a
33+
ConfigFact :: FactsSelection [Fact ConfigKey Config]
34+
WhiteListedFacts :: FactsSelection [Fact WhiteListKey ()]
3135
AllFacts :: FactsSelection [Fact JSValue JSValue]
36+
3237
retrieveAnyFacts
3338
:: (FromJSON Maybe k, FromJSON Maybe v, Functor m)
3439
=> MPFS m
@@ -59,4 +64,6 @@ factsCmd mpfs tokenId (TestRunFacts TestRunRejected) = do
5964
_ -> False
6065
)
6166
facts
67+
factsCmd mpfs tokenId ConfigFact = retrieveAnyFacts mpfs tokenId
68+
factsCmd mpfs tokenId WhiteListedFacts = retrieveAnyFacts mpfs tokenId
6269
factsCmd mpfs tokenId AllFacts = retrieveAnyFacts mpfs tokenId

cli/src/Options.hs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module Options
1313
) where
1414

1515
import Cli (Command (..))
16+
import Control.Applicative (optional)
1617
import Core.Options
1718
( outputReferenceParser
1819
, tokenIdOption
@@ -27,13 +28,13 @@ import OptEnvConf
2728
( Parser
2829
, command
2930
, commands
30-
, runParser, (<|>)
31+
, runParser
32+
, (<|>)
3133
)
3234
import Oracle.Options (oracleCommandParser)
3335
import User.Agent.Options (agentCommandParser)
3436
import User.Requester.Options (requesterCommandParser)
3537
import Wallet.Options (walletCommandParser)
36-
import Control.Applicative (optional)
3738

3839
newtype Options a = Options
3940
{ optionsCommand :: Command a
@@ -78,7 +79,16 @@ factsSelectionParser =
7879
"test-run"
7980
"Get test runs"
8081
(fmapBox TestRunFacts <$> testRunSelectionParser)
81-
] <|> pure (Box AllFacts)
82+
, command
83+
"config"
84+
"Get the oracle configuration"
85+
(pure $ Box ConfigFact)
86+
, command
87+
"white-listed"
88+
"Get white-listed repositories"
89+
(pure $ Box WhiteListedFacts)
90+
]
91+
<|> pure (Box AllFacts)
8292

8393
testRunSelectionParser :: Parser (Box TestRunSelection)
8494
testRunSelectionParser =

0 commit comments

Comments
 (0)