Skip to content

Commit

Permalink
Rename CLI transaction list time range options.
Browse files Browse the repository at this point in the history
Use `--start` and `--end` instead of `--after` and `--before`.

See: #467 (comment)
  • Loading branch information
jonathanknowles committed Jul 24, 2019
1 parent 1f010a3 commit d1a506d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 33 deletions.
34 changes: 17 additions & 17 deletions lib/cli/src/Cardano/CLI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,8 @@ cmdTransactionFees = command "fees" $ info (helper <*> cmd) $ mempty
data TransactionListArgs = TransactionListArgs
{ _port :: Port "Wallet"
, _walletId :: WalletId
, _timeAfter :: Maybe Iso8601Time
, _timeBefore :: Maybe Iso8601Time
, _timeRangeStart :: Maybe Iso8601Time
, _timeRangeEnd :: Maybe Iso8601Time
}

cmdTransactionList
Expand All @@ -581,15 +581,15 @@ cmdTransactionList = command "list" $ info (helper <*> cmd) $ mempty
cmd = fmap exec $ TransactionListArgs
<$> portOption
<*> walletIdArgument
<*> optional timeAfterOption
<*> optional timeBeforeOption
exec (TransactionListArgs wPort wId mTimeAfter mTimeBefore) =
<*> optional timeRangeStartOption
<*> optional timeRangeEndOption
exec (TransactionListArgs wPort wId mTimeRangeStart mTimeRangeEnd) =
runClient wPort Aeson.encodePretty $ listTransactions
(walletClient @t)
(ApiT wId)
(pure $ Iso8601Range
(getIso8601Time <$> mTimeAfter)
(getIso8601Time <$> mTimeBefore))
(getIso8601Time <$> mTimeRangeStart)
(getIso8601Time <$> mTimeRangeEnd))

{-------------------------------------------------------------------------------
Commands - 'address'
Expand Down Expand Up @@ -748,20 +748,20 @@ stateDirOption backendDir = optional $ strOption $ mempty
where
defaultDir = backendDir </> "NETWORK"

-- | [--after=TIME]
timeAfterOption :: Parser Iso8601Time
timeAfterOption = optionT $ mempty
<> long "after"
-- | [--start=TIME]
timeRangeStartOption :: Parser Iso8601Time
timeRangeStartOption = optionT $ mempty
<> long "start"
<> metavar "TIME"
<> help "specifies an earliest time (ISO 8601 format: basic or extended)"
<> help "specifies a start time (ISO 8601 format: basic or extended)."
<> showDefaultWith showT

-- | [--before=TIME]
timeBeforeOption :: Parser Iso8601Time
timeBeforeOption = optionT $ mempty
<> long "before"
-- | [--end=TIME]
timeRangeEndOption :: Parser Iso8601Time
timeRangeEndOption = optionT $ mempty
<> long "end"
<> metavar "TIME"
<> help "specifies a latest time (ISO 8601 format: basic or extended)"
<> help "specifies an end time (ISO 8601 format: basic or extended)."
<> showDefaultWith showT

-- | [(--quiet|--verbose)]
Expand Down
12 changes: 6 additions & 6 deletions lib/cli/test/unit/Cardano/CLISpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -258,18 +258,18 @@ spec = do
]

["transaction", "list", "--help"] `shouldShowUsage`
[ "Usage: transaction list [--port INT] WALLET_ID [--after TIME]"
, " [--before TIME]"
[ "Usage: transaction list [--port INT] WALLET_ID [--start TIME]"
, " [--end TIME]"
, " List the transactions associated with a wallet."
, ""
, "Available options:"
, " -h,--help Show this help text"
, " --port INT port used for serving the wallet"
, " API. (default: 8090)"
, " --after TIME specifies an earliest time (ISO 8601"
, " format: basic or extended)"
, " --before TIME specifies a latest time (ISO 8601"
, " format: basic or extended)"
, " --start TIME specifies a start time (ISO 8601"
, " format: basic or extended)."
, " --end TIME specifies an end time (ISO 8601"
, " format: basic or extended)."
]

["address", "--help"] `shouldShowUsage`
Expand Down
15 changes: 8 additions & 7 deletions lib/core/test/integration/Test/Integration/Framework/DSL.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1078,13 +1078,14 @@ listTransactionsViaCLI
-> Maybe Iso8601Time
-> Maybe Iso8601Time
-> IO r
listTransactionsViaCLI ctx wallet mAfter mBefore = cardanoWalletCLI @t $ join
[ ["transaction", "list"]
, ["--port", show (ctx ^. typed @Port)]
, [T.unpack $ wallet ^. walletId]
, maybe [] (\t -> ["--after", showT t]) mAfter
, maybe [] (\t -> ["--before", showT t]) mBefore
]
listTransactionsViaCLI ctx wallet mTimeRangeStart mTimeRangeEnd =
cardanoWalletCLI @t $ join
[ ["transaction", "list"]
, ["--port", show (ctx ^. typed @Port)]
, [T.unpack $ wallet ^. walletId]
, maybe [] (\t -> ["--start", showT t]) mTimeRangeStart
, maybe [] (\t -> ["--end", showT t]) mTimeRangeEnd
]

-- There is a dependency cycle in the packages.
--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -652,12 +652,12 @@ spec = do
c `shouldBe` ExitFailure 1

it "TRANS_LIST_01 - Listing transactions for an empty wallet" $ \ctx ->
withMaxSuccess 10 $ property $ \mAfter mBefore -> do
withMaxSuccess 10 $ property $ \mTimeRangeStart mTimeRangeEnd -> do
wallet <- emptyWallet ctx
(Exit code, Stdout out, Stderr err) <-
listTransactionsViaCLI @t ctx wallet
(Iso8601Time <$> mAfter)
(Iso8601Time <$> mBefore)
(Iso8601Time <$> mTimeRangeStart)
(Iso8601Time <$> mTimeRangeEnd)
err `shouldBe` "Ok.\n"
out `shouldBe` "[]\n"
code `shouldBe` ExitSuccess
Expand Down

0 comments on commit d1a506d

Please sign in to comment.