Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI golden tests for common command usage #537

Merged
merged 4 commits into from
Jul 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions exe/wallet/http-bridge/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,9 @@ main = runCli $ cli $ mempty

{-------------------------------------------------------------------------------
Command - 'launch'

cardano-wallet launch
[--network=STRING]
[(--port=INT | --random-port)]
[--node-port=INT]
[--state-dir=DIR]
[(--quiet | --verbose )]
-------------------------------------------------------------------------------}

-- | Arguments for the 'launch' command
data LaunchArgs = LaunchArgs
{ _network :: Either Local Network
, _listen :: Listen
Expand All @@ -157,7 +151,6 @@ data LaunchArgs = LaunchArgs
, _verbosity :: Verbosity
}

-- | cardano-wallet launch
cmdLaunch
:: Mod CommandFields (IO ())
cmdLaunch = command "launch" $ info (helper <*> cmd) $ mempty
Expand Down Expand Up @@ -210,13 +203,6 @@ cmdLaunch = command "launch" $ info (helper <*> cmd) $ mempty

{-------------------------------------------------------------------------------
Command - 'serve'

cardano-wallet serve
[--network=STRING]
[(--port=INT | --random-port)]
[--node-port=INT]
[--database=FILE]
[(--quiet | --verbose )]
-------------------------------------------------------------------------------}

-- | Arguments for the 'serve' command
Expand All @@ -228,7 +214,6 @@ data ServeArgs = ServeArgs
, _verbosity :: Verbosity
}

-- | cardano-wallet serve
cmdServe
:: Mod CommandFields (IO ())
cmdServe = command "serve" $ info (helper <*> cmd) $ mempty
Expand Down
19 changes: 1 addition & 18 deletions exe/wallet/jormungandr/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,9 @@ main = runCli $ cli $ mempty

{-------------------------------------------------------------------------------
Command - 'launch'

cardano-wallet launch
[(--port=INT | --random-port)]
[--node-port=INT]
[--state-dir=DIR]
[(--quiet | --verbose )]
--genesis-block=FILE
--bft-leaders=FILE
-------------------------------------------------------------------------------}

-- | Arguments for the 'launch' command
data LaunchArgs = LaunchArgs
{ _listen :: Listen
, _nodePort :: Port "Node"
Expand All @@ -189,7 +182,6 @@ data JormungandrArgs = JormungandrArgs
, _bftLeaders :: FilePath
}

-- | cardano-wallet launch
cmdLaunch
:: Mod CommandFields (IO ())
cmdLaunch = command "launch" $ info (helper <*> cmd) $ mempty
Expand Down Expand Up @@ -267,14 +259,6 @@ parseBlock0H file = do

{-------------------------------------------------------------------------------
Command - 'serve'

cardano-wallet serve
[--network=STRING]
[(--port=INT | --random-port)]
[--node-port=INT]
[--database=FILE]
[(--quiet | --verbose )]
--genesis-hash=STRING
-------------------------------------------------------------------------------}

-- | Arguments for the 'serve' command
Expand All @@ -286,7 +270,6 @@ data ServeArgs = ServeArgs
, _block0H :: Hash "Genesis"
}

-- | cardano-wallet serve
cmdServe
:: Mod CommandFields (IO ())
cmdServe = command "serve" $ info (helper <*> cmd) $ mempty
Expand Down
4 changes: 4 additions & 0 deletions lib/cli/cardano-wallet-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@ test-suite unit
-Werror
build-depends:
base
, cardano-crypto
, cardano-wallet-cli
, cardano-wallet-core
, hspec
, memory
, optparse-applicative
, QuickCheck
, quickcheck-instances
, text
Expand Down
31 changes: 0 additions & 31 deletions lib/cli/src/Cardano/CLI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,8 @@ runCli = join . customExecParser preferences

{-------------------------------------------------------------------------------
Commands - 'mnemonic'

cardano-wallet mnemonic generate [--size=INT]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you plan to also remove the comments on functions like the one below:

-- | cardano-wallet mnemonic generate [--size=INT]
cmdMnemonicGenerate :: Mod CommandFields (IO ())         

It seems these are now superfluous, as we have:

["mnemonic", "generate", "--help"] `shouldShowUsage`  
    [ "Usage:  mnemonic generate [--size INT]"
    , "  Generate English BIP-0039 compatible mnemonic words."

-------------------------------------------------------------------------------}

-- | cardano-wallet mnemonic
cmdMnemonic :: Mod CommandFields (IO ())
cmdMnemonic = command "mnemonic" $ info (helper <*> cmds) mempty
where
Expand All @@ -285,7 +282,6 @@ newtype MnemonicGenerateArgs = MnemonicGenerateArgs
{ _size :: MnemonicSize
}

-- | cardano-wallet mnemonic generate [--size=INT]
cmdMnemonicGenerate :: Mod CommandFields (IO ())
cmdMnemonicGenerate = command "generate" $ info (helper <*> cmd) $ mempty
<> progDesc "Generate English BIP-0039 compatible mnemonic words."
Expand All @@ -303,16 +299,8 @@ cmdMnemonicGenerate = command "generate" $ info (helper <*> cmd) $ mempty

{-------------------------------------------------------------------------------
Commands - 'wallet'

cardano-wallet wallet list [--port=INT]
cardano-wallet wallet create [--port=INT] <name> [--address-pool-gap=INT]
cardano-wallet wallet get [--port=INT] <wallet-id>
cardano-wallet wallet update name [--port=INT] <wallet-id> STRING
cardano-wallet wallet update passphrase [--port=INT] <wallet-id>
cardano-wallet wallet delete [--port=INT] <wallet-id>
-------------------------------------------------------------------------------}

-- | cardano-wallet wallet
cmdWallet
:: forall t. (DecodeAddress t, EncodeAddress t)
=> Mod CommandFields (IO ())
Expand All @@ -330,7 +318,6 @@ newtype WalletListArgs = WalletListArgs
{ _port :: Port "Wallet"
}

-- | cardano-wallet wallet list [--port=INT]
cmdWalletList
:: forall t. (DecodeAddress t, EncodeAddress t)
=> Mod CommandFields (IO ())
Expand All @@ -348,7 +335,6 @@ data WalletCreateArgs = WalletCreateArgs
, _gap :: AddressPoolGap
}

-- | cardano-wallet wallet create [--port=INT] <name> [--address-pool-gap=INT]
cmdWalletCreate
:: forall t. (DecodeAddress t, EncodeAddress t)
=> Mod CommandFields (IO ())
Expand Down Expand Up @@ -389,7 +375,6 @@ data WalletGetArgs = WalletGetArgs
, _id :: WalletId
}

-- | cardano-wallet wallet get [--port=INT] <wallet-id>
cmdWalletGet
:: forall t. (DecodeAddress t, EncodeAddress t)
=> Mod CommandFields (IO ())
Expand Down Expand Up @@ -420,7 +405,6 @@ data WalletUpdateNameArgs = WalletUpdateNameArgs
, _name :: WalletName
}

-- | cardano-wallet wallet update name [--port=INT] <wallet-id> STRING
cmdWalletUpdateName
:: forall t. (DecodeAddress t, EncodeAddress t)
=> Mod CommandFields (IO ())
Expand All @@ -442,7 +426,6 @@ data WalletUpdatePassphraseArgs = WalletUpdatePassphraseArgs
, _id :: WalletId
}

-- | cardano-wallet wallet update passphrase [--port=INT] <wallet-id>
cmdWalletUpdatePassphrase
:: forall t. (DecodeAddress t, EncodeAddress t)
=> Mod CommandFields (IO ())
Expand Down Expand Up @@ -474,7 +457,6 @@ data WalletDeleteArgs = WalletDeleteArgs
, _id :: WalletId
}

-- | cardano-wallet wallet delete [--port=INT] <wallet-id>
cmdWalletDelete
:: forall t. (DecodeAddress t, EncodeAddress t)
=> Mod CommandFields (IO ())
Expand All @@ -490,9 +472,6 @@ cmdWalletDelete = command "delete" $ info (helper <*> cmd) $ mempty

{-------------------------------------------------------------------------------
Commands - 'transaction'

cardano-wallet transaction create [--port=INT] <wallet-id> --payment=PAYMENT...
cardano-wallet transaction fees [--port=INT] <wallet-id> --payment=PAYMENT...
-------------------------------------------------------------------------------}

-- | cardano-wallet transaction
Expand All @@ -512,7 +491,6 @@ data TransactionCreateArgs t = TransactionCreateArgs
, _payments :: NonEmpty (AddressAmount t)
}

-- | cardano-wallet wallet list [--port=INT]
cmdTransactionCreate
:: forall t. (DecodeAddress t, EncodeAddress t)
=> Mod CommandFields (IO ())
Expand Down Expand Up @@ -558,11 +536,8 @@ cmdTransactionFees = command "fees" $ info (helper <*> cmd) $ mempty

{-------------------------------------------------------------------------------
Commands - 'address'

cardano-wallet address list [--port=INT] [--state=STRING] <wallet-id>
-------------------------------------------------------------------------------}

-- | cardano-wallet address
cmdAddress
:: forall t. (DecodeAddress t, EncodeAddress t)
=> Mod CommandFields (IO ())
Expand All @@ -578,7 +553,6 @@ data AddressListArgs = AddressListArgs
, _id :: WalletId
}

-- | cardano-wallet address list [--port=INT] [--state=STRING] <wallet-id>
cmdAddressList
:: forall t. (DecodeAddress t, EncodeAddress t)
=> Mod CommandFields (IO ())
Expand All @@ -596,11 +570,8 @@ cmdAddressList = command "list" $ info (helper <*> cmd) $ mempty

{-------------------------------------------------------------------------------
Commands - 'version'

cardano-wallet version
-------------------------------------------------------------------------------}

-- | cardano-wallet version
cmdVersion :: Mod CommandFields (IO ())
cmdVersion = command "version" $ info cmd $ mempty
<> progDesc "Show the program's version."
Expand All @@ -612,8 +583,6 @@ cmdVersion = command "version" $ info cmd $ mempty

{-------------------------------------------------------------------------------
Commands - 'launch'

cardano-wallet launch ...
-------------------------------------------------------------------------------}

-- | Execute 'launch' commands. This differs from the 'serve' command as it
Expand Down
Loading