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

Move node commands to top level #929

Merged
merged 4 commits into from
Oct 8, 2024
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
6 changes: 3 additions & 3 deletions cardano-cli/cardano-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ library
Cardano.CLI.Commands.Debug.LogEpochState
Cardano.CLI.Commands.Debug.TransactionView
Cardano.CLI.Commands.Hash
Cardano.CLI.Commands.Node
Cardano.CLI.Commands.Ping
Cardano.CLI.Environment
Cardano.CLI.EraBased.Commands
Expand All @@ -74,7 +75,6 @@ library
Cardano.CLI.EraBased.Commands.Governance.Poll
Cardano.CLI.EraBased.Commands.Governance.Vote
Cardano.CLI.EraBased.Commands.Key
Cardano.CLI.EraBased.Commands.Node
Cardano.CLI.EraBased.Commands.Query
Cardano.CLI.EraBased.Commands.StakeAddress
Cardano.CLI.EraBased.Commands.StakePool
Expand All @@ -90,7 +90,6 @@ library
Cardano.CLI.EraBased.Options.Governance.Poll
Cardano.CLI.EraBased.Options.Governance.Vote
Cardano.CLI.EraBased.Options.Key
Cardano.CLI.EraBased.Options.Node
Cardano.CLI.EraBased.Options.Query
Cardano.CLI.EraBased.Options.StakeAddress
Cardano.CLI.EraBased.Options.StakePool
Expand All @@ -110,7 +109,6 @@ library
Cardano.CLI.EraBased.Run.Governance.Poll
Cardano.CLI.EraBased.Run.Governance.Vote
Cardano.CLI.EraBased.Run.Key
Cardano.CLI.EraBased.Run.Node
Cardano.CLI.EraBased.Run.Query
Cardano.CLI.EraBased.Run.StakeAddress
Cardano.CLI.EraBased.Run.StakePool
Expand All @@ -131,6 +129,7 @@ library
Cardano.CLI.Options
Cardano.CLI.Options.Debug
Cardano.CLI.Options.Hash
Cardano.CLI.Options.Node
Cardano.CLI.Options.Ping
Cardano.CLI.Orphans
Cardano.CLI.Parser
Expand All @@ -142,6 +141,7 @@ library
Cardano.CLI.Run.Debug.LogEpochState
Cardano.CLI.Run.Debug.TransactionView
Cardano.CLI.Run.Hash
Cardano.CLI.Run.Node
Cardano.CLI.Run.Ping
Cardano.CLI.TopHandler
Cardano.CLI.Types.Common
Expand Down
3 changes: 3 additions & 0 deletions cardano-cli/src/Cardano/CLI/Commands.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ where
import Cardano.CLI.Byron.Commands (ByronCommand)
import Cardano.CLI.Commands.Debug
import Cardano.CLI.Commands.Hash (HashCmds)
import Cardano.CLI.Commands.Node
import Cardano.CLI.Commands.Ping (PingCmd (..))
import Cardano.CLI.EraBased.Commands
import Cardano.CLI.Legacy.Commands
Expand All @@ -21,6 +22,8 @@ data ClientCommand
ByronCommand ByronCommand
| -- | Era-agnostic hashing commands
HashCmds HashCmds
| -- | Era agnostic node commands
NodeCommands NodeCmds
| -- | Legacy shelley-based Commands
LegacyCmds LegacyCmds
| CliPingCommand PingCmd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE LambdaCase #-}

module Cardano.CLI.EraBased.Commands.Node
module Cardano.CLI.Commands.Node
( NodeCmds (..)
, renderNodeCmds
, NodeKeyGenColdCmdArgs (..)
Expand All @@ -21,7 +21,7 @@ import Cardano.CLI.Types.Key

import Data.Text (Text)

data NodeCmds era
data NodeCmds
= NodeKeyGenColdCmd !NodeKeyGenColdCmdArgs
| NodeKeyGenKESCmd !NodeKeyGenKESCmdArgs
| NodeKeyGenVRFCmd !NodeKeyGenVRFCmdArgs
Expand Down Expand Up @@ -84,7 +84,7 @@ data NodeIssueOpCertCmdArgs
}
deriving Show

renderNodeCmds :: NodeCmds era -> Text
renderNodeCmds :: NodeCmds -> Text
renderNodeCmds = \case
NodeKeyGenColdCmd{} -> "node key-gen"
NodeKeyGenKESCmd{} -> "node key-gen-KES"
Expand Down
8 changes: 4 additions & 4 deletions cardano-cli/src/Cardano/CLI/EraBased/Commands.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ where

import Cardano.Api (ShelleyBasedEra (..), toCardanoEra)

import Cardano.CLI.Commands.Node
import Cardano.CLI.Environment
import Cardano.CLI.EraBased.Commands.Address
import Cardano.CLI.EraBased.Commands.Genesis
import Cardano.CLI.EraBased.Commands.Key
import Cardano.CLI.EraBased.Commands.Node
import Cardano.CLI.EraBased.Commands.Query
import Cardano.CLI.EraBased.Commands.StakeAddress
import Cardano.CLI.EraBased.Commands.StakePool hiding (sbe)
Expand All @@ -28,12 +28,12 @@ import Cardano.CLI.EraBased.Options.Common
import Cardano.CLI.EraBased.Options.Genesis
import Cardano.CLI.EraBased.Options.Governance
import Cardano.CLI.EraBased.Options.Key
import Cardano.CLI.EraBased.Options.Node
import Cardano.CLI.EraBased.Options.Query
import Cardano.CLI.EraBased.Options.StakeAddress
import Cardano.CLI.EraBased.Options.StakePool
import Cardano.CLI.EraBased.Options.TextView
import Cardano.CLI.EraBased.Options.Transaction
import Cardano.CLI.Options.Node

import Data.Foldable
import Data.Maybe
Expand All @@ -54,7 +54,7 @@ data Cmds era
| KeyCmds (KeyCmds era)
| GenesisCmds (GenesisCmds era)
| GovernanceCmds (GovernanceCmds era)
| NodeCmds (NodeCmds era)
| NodeCmds NodeCmds
| QueryCmds (QueryCmds era)
| StakeAddressCmds (StakeAddressCmds era)
| StakePoolCmds (StakePoolCmds era)
Expand Down Expand Up @@ -121,7 +121,7 @@ pCmds sbe' envCli = do
, fmap KeyCmds <$> pKeyCmds
, fmap GenesisCmds <$> pGenesisCmds cEra envCli
, fmap GovernanceCmds <$> pGovernanceCmds cEra
, fmap NodeCmds <$> pNodeCmds
, Just (NodeCmds <$> pNodeCmds)
, fmap QueryCmds <$> pQueryCmds cEra envCli
, fmap StakeAddressCmds <$> pStakeAddressCmds cEra envCli
, fmap StakePoolCmds <$> pStakePoolCmds cEra envCli
Expand Down
133 changes: 0 additions & 133 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Node.hs

This file was deleted.

2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/EraBased/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import Cardano.CLI.EraBased.Run.Address
import Cardano.CLI.EraBased.Run.Genesis
import Cardano.CLI.EraBased.Run.Governance
import Cardano.CLI.EraBased.Run.Key
import Cardano.CLI.EraBased.Run.Node
import Cardano.CLI.EraBased.Run.Query
import Cardano.CLI.EraBased.Run.StakeAddress
import Cardano.CLI.EraBased.Run.StakePool
import Cardano.CLI.EraBased.Run.TextView
import Cardano.CLI.EraBased.Run.Transaction
import Cardano.CLI.Helpers (printEraDeprecationWarning)
import Cardano.CLI.Run.Node
import Cardano.CLI.Types.Errors.CmdError

import Data.Function ((&))
Expand Down
6 changes: 3 additions & 3 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ import Cardano.Chain.Update hiding (ProtocolParameters)
import Cardano.CLI.Byron.Delegation
import Cardano.CLI.Byron.Genesis as Byron
import qualified Cardano.CLI.Byron.Key as Byron
import qualified Cardano.CLI.Commands.Node as Cmd
import Cardano.CLI.EraBased.Commands.Genesis as Cmd
import qualified Cardano.CLI.EraBased.Commands.Node as Cmd
import Cardano.CLI.EraBased.Run.Genesis.Common
import qualified Cardano.CLI.EraBased.Run.Genesis.CreateTestnetData as TN
import Cardano.CLI.EraBased.Run.Node (runNodeIssueOpCertCmd, runNodeKeyGenColdCmd,
runNodeKeyGenKesCmd, runNodeKeyGenVrfCmd)
import Cardano.CLI.EraBased.Run.StakeAddress (runStakeAddressKeyGenCmd)
import qualified Cardano.CLI.IO.Lazy as Lazy
import Cardano.CLI.Run.Node (runNodeIssueOpCertCmd, runNodeKeyGenColdCmd,
runNodeKeyGenKesCmd, runNodeKeyGenVrfCmd)
import Cardano.CLI.Types.Common
import Cardano.CLI.Types.Errors.GenesisCmdError
import Cardano.CLI.Types.Errors.NodeCmdError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ import Cardano.Api.Shelley
VrfKey, alonzoGenesisDefaults, conwayGenesisDefaults, shelleyGenesisDefaults,
toShelleyAddr, toShelleyNetwork, toShelleyStakeAddr)

import qualified Cardano.CLI.Commands.Node as Cmd
import Cardano.CLI.EraBased.Commands.Genesis as Cmd
import qualified Cardano.CLI.EraBased.Commands.Governance.DRep as DRep
import qualified Cardano.CLI.EraBased.Commands.Node as Cmd
import Cardano.CLI.EraBased.Run.Address (generateAndWriteKeyFiles)
import Cardano.CLI.EraBased.Run.Genesis.Common
import qualified Cardano.CLI.EraBased.Run.Governance.DRep as DRep
import qualified Cardano.CLI.EraBased.Run.Key as Key
import Cardano.CLI.EraBased.Run.Node (runNodeIssueOpCertCmd, runNodeKeyGenColdCmd,
runNodeKeyGenKesCmd, runNodeKeyGenVrfCmd)
import Cardano.CLI.EraBased.Run.StakeAddress (runStakeAddressKeyGenCmd)
import qualified Cardano.CLI.IO.Lazy as Lazy
import Cardano.CLI.Run.Node (runNodeIssueOpCertCmd, runNodeKeyGenColdCmd,
runNodeKeyGenKesCmd, runNodeKeyGenVrfCmd)
import Cardano.CLI.Types.Common
import Cardano.CLI.Types.Errors.GenesisCmdError
import Cardano.CLI.Types.Errors.NodeCmdError
Expand Down
9 changes: 8 additions & 1 deletion cardano-cli/src/Cardano/CLI/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Cardano.CLI.EraBased.Options.Common
import Cardano.CLI.Legacy.Options (parseLegacyCmds)
import Cardano.CLI.Options.Debug
import Cardano.CLI.Options.Hash
import Cardano.CLI.Options.Node
import Cardano.CLI.Options.Ping (parsePingCmd)
import Cardano.CLI.Render (customRenderHelp)
import Cardano.CLI.Run (ClientCommand (..))
Expand Down Expand Up @@ -47,13 +48,19 @@ pref =
, helpRenderHelp customRenderHelp
]

-- 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
nodeCmdsTopLevel = NodeCommands <$> pNodeCmds

parseClientCommand :: EnvCli -> Parser ClientCommand
parseClientCommand envCli =
asum
-- 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.
[ parseLegacy envCli
[ nodeCmdsTopLevel
, parseLegacy envCli
, parseByron envCli
, parseAnyEra envCli
, parseHash
Expand Down
Loading
Loading