Skip to content

Commit

Permalink
Expose address commands at cli top level
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimbo4350 committed Oct 10, 2024
1 parent d1157a3 commit 8d13e05
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cardano-cli/src/Cardano/CLI/Commands.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module Cardano.CLI.Commands
where

import Cardano.CLI.Byron.Commands (ByronCommand)
import Cardano.CLI.Commands.Address
import Cardano.CLI.Commands.Debug
import Cardano.CLI.Commands.Hash (HashCmds)
import Cardano.CLI.Commands.Key
Expand All @@ -19,6 +20,7 @@ import Options.Applicative.Types (ParserInfo (..), ParserPrefs (..))
-- | Sub-commands of 'cardano-cli'.
data ClientCommand
= AnyEraCommand AnyEraCommand
| AddressCommand AddressCmds
| -- | Byron Related Commands
ByronCommand ByronCommand
| -- | Era agnostic hashing commands
Expand Down
7 changes: 6 additions & 1 deletion cardano-cli/src/Cardano/CLI/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Cardano.CLI.Environment (EnvCli)
import Cardano.CLI.EraBased.Commands
import Cardano.CLI.EraBased.Options.Common
import Cardano.CLI.Legacy.Options (parseLegacyCmds)
import Cardano.CLI.Options.Address
import Cardano.CLI.Options.Debug
import Cardano.CLI.Options.Hash
import Cardano.CLI.Options.Key
Expand Down Expand Up @@ -49,6 +50,9 @@ pref =
, helpRenderHelp customRenderHelp
]

addressCmdsTopLevel :: EnvCli -> Parser ClientCommand
addressCmdsTopLevel envCli = AddressCommand <$> pAddressCmds envCli

-- The node related commands are shelley era agnostic for the time being.
-- There is no need to guard them by the era argument.
nodeCmdsTopLevel :: Parser ClientCommand
Expand All @@ -63,7 +67,8 @@ parseClientCommand envCli =
-- There are name clashes between Shelley commands and the Byron backwards
-- compat commands (e.g. "genesis"), and we need to prefer the Shelley ones
-- so we list it first.
[ keyCmdsTopLevel
[ addressCmdsTopLevel envCli
, keyCmdsTopLevel
, nodeCmdsTopLevel
, parseLegacy envCli
, parseByron envCli
Expand Down
7 changes: 7 additions & 0 deletions cardano-cli/src/Cardano/CLI/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ import Cardano.CLI.EraBased.Run
import Cardano.CLI.Legacy.Commands
import Cardano.CLI.Legacy.Run (runLegacyCmds)
import Cardano.CLI.Render (customRenderHelp)
import Cardano.CLI.Run.Address
import Cardano.CLI.Run.Debug
import Cardano.CLI.Run.Hash (runHashCmds)
import Cardano.CLI.Run.Key
import Cardano.CLI.Run.Node
import Cardano.CLI.Run.Ping (PingClientCmdError (..), renderPingClientCmdError,
runPingCmd)
import Cardano.CLI.Types.Errors.AddressCmdError
import Cardano.CLI.Types.Errors.CmdError
import Cardano.CLI.Types.Errors.HashCmdError
import Cardano.CLI.Types.Errors.KeyCmdError
Expand All @@ -50,6 +52,7 @@ import Paths_cardano_cli (version)

data ClientCommandErrors
= ByronClientError ByronClientCmdError
| AddressCmdError AddressCmdError
| CmdError Text CmdError
| HashCmdError HashCmdError
| KeyCmdError KeyCmdError
Expand All @@ -61,6 +64,8 @@ runClientCommand :: ClientCommand -> ExceptT ClientCommandErrors IO ()
runClientCommand = \case
AnyEraCommand cmds ->
firstExceptT (CmdError (renderAnyEraCommand cmds)) $ runAnyEraCommand cmds
AddressCommand cmds ->
firstExceptT AddressCmdError $ runAddressCmds cmds
NodeCommands cmds ->
runNodeCmds cmds
& firstExceptT NodeCmdError
Expand All @@ -87,6 +92,8 @@ renderClientCommandError = \case
renderCmdError cmdText err
ByronClientError err ->
renderByronClientCmdError err
AddressCmdError err ->
renderAddressCmdError err
HashCmdError err ->
prettyError err
NodeCmdError err ->
Expand Down

0 comments on commit 8d13e05

Please sign in to comment.