Skip to content

Commit

Permalink
Merge pull request #931 from IntersectMBO/jordan/move-key-commands-to…
Browse files Browse the repository at this point in the history
…-top-level

Move key commands to top level
  • Loading branch information
Jimbo4350 authored Oct 10, 2024
2 parents 7d13953 + f2d454b commit 184b794
Show file tree
Hide file tree
Showing 25 changed files with 379 additions and 109 deletions.
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.Key
Cardano.CLI.Commands.Node
Cardano.CLI.Commands.Ping
Cardano.CLI.Environment
Expand All @@ -74,7 +75,6 @@ library
Cardano.CLI.EraBased.Commands.Governance.DRep
Cardano.CLI.EraBased.Commands.Governance.Poll
Cardano.CLI.EraBased.Commands.Governance.Vote
Cardano.CLI.EraBased.Commands.Key
Cardano.CLI.EraBased.Commands.Query
Cardano.CLI.EraBased.Commands.StakeAddress
Cardano.CLI.EraBased.Commands.StakePool
Expand All @@ -89,7 +89,6 @@ library
Cardano.CLI.EraBased.Options.Governance.DRep
Cardano.CLI.EraBased.Options.Governance.Poll
Cardano.CLI.EraBased.Options.Governance.Vote
Cardano.CLI.EraBased.Options.Key
Cardano.CLI.EraBased.Options.Query
Cardano.CLI.EraBased.Options.StakeAddress
Cardano.CLI.EraBased.Options.StakePool
Expand All @@ -108,7 +107,6 @@ library
Cardano.CLI.EraBased.Run.Governance.GenesisKeyDelegationCertificate
Cardano.CLI.EraBased.Run.Governance.Poll
Cardano.CLI.EraBased.Run.Governance.Vote
Cardano.CLI.EraBased.Run.Key
Cardano.CLI.EraBased.Run.Query
Cardano.CLI.EraBased.Run.StakeAddress
Cardano.CLI.EraBased.Run.StakePool
Expand All @@ -129,6 +127,7 @@ library
Cardano.CLI.Options
Cardano.CLI.Options.Debug
Cardano.CLI.Options.Hash
Cardano.CLI.Options.Key
Cardano.CLI.Options.Node
Cardano.CLI.Options.Ping
Cardano.CLI.Orphans
Expand All @@ -141,6 +140,7 @@ library
Cardano.CLI.Run.Debug.LogEpochState
Cardano.CLI.Run.Debug.TransactionView
Cardano.CLI.Run.Hash
Cardano.CLI.Run.Key
Cardano.CLI.Run.Node
Cardano.CLI.Run.Ping
Cardano.CLI.TopHandler
Expand Down
5 changes: 4 additions & 1 deletion 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.Key
import Cardano.CLI.Commands.Node
import Cardano.CLI.Commands.Ping (PingCmd (..))
import Cardano.CLI.EraBased.Commands
Expand All @@ -20,8 +21,10 @@ data ClientCommand
= AnyEraCommand AnyEraCommand
| -- | Byron Related Commands
ByronCommand ByronCommand
| -- | Era-agnostic hashing commands
| -- | Era agnostic hashing commands
HashCmds HashCmds
| -- | Era agnostic key commands
KeyCommands KeyCmds
| -- | Era agnostic node commands
NodeCommands NodeCmds
| -- | Legacy shelley-based Commands
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.Key
module Cardano.CLI.Commands.Key
( KeyCmds (..)
, KeyVerificationKeyCmdArgs (..)
, KeyNonExtendedKeyCmdArgs (..)
Expand All @@ -22,7 +22,7 @@ import Cardano.CLI.Types.Common

import Data.Text (Text)

data KeyCmds era
data KeyCmds
= KeyVerificationKeyCmd !KeyVerificationKeyCmdArgs
| KeyNonExtendedKeyCmd !KeyNonExtendedKeyCmdArgs
| KeyConvertByronKeyCmd !KeyConvertByronKeyCmdArgs
Expand Down Expand Up @@ -118,7 +118,7 @@ data KeyConvertCardanoAddressKeyCmdArgs = KeyConvertCardanoAddressKeyCmdArgs
}
deriving Show

renderKeyCmds :: KeyCmds era -> Text
renderKeyCmds :: KeyCmds -> Text
renderKeyCmds = \case
KeyVerificationKeyCmd{} ->
"key verification-key"
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.Key
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.Query
import Cardano.CLI.EraBased.Commands.StakeAddress
import Cardano.CLI.EraBased.Commands.StakePool hiding (sbe)
Expand All @@ -27,12 +27,12 @@ import Cardano.CLI.EraBased.Options.Address
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.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.Key
import Cardano.CLI.Options.Node

import Data.Foldable
Expand All @@ -51,7 +51,7 @@ renderAnyEraCommand = \case

data Cmds era
= AddressCmds (AddressCmds era)
| KeyCmds (KeyCmds era)
| KeyCmds KeyCmds
| GenesisCmds (GenesisCmds era)
| GovernanceCmds (GovernanceCmds era)
| NodeCmds NodeCmds
Expand Down Expand Up @@ -118,7 +118,7 @@ pCmds sbe' envCli = do
asum $
catMaybes
[ fmap AddressCmds <$> pAddressCmds cEra envCli
, fmap KeyCmds <$> pKeyCmds
, Just (KeyCmds <$> pKeyCmds)
, fmap GenesisCmds <$> pGenesisCmds cEra envCli
, fmap GovernanceCmds <$> pGovernanceCmds cEra
, Just (NodeCmds <$> pNodeCmds)
Expand Down
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 @@ -14,13 +14,13 @@ import Cardano.CLI.EraBased.Commands
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.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.Key
import Cardano.CLI.Run.Node
import Cardano.CLI.Types.Errors.CmdError

Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/EraBased/Run/Address.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import Cardano.Api.Shelley

import Cardano.CLI.EraBased.Commands.Address
import Cardano.CLI.EraBased.Run.Address.Info
import qualified Cardano.CLI.EraBased.Run.Key as Key
import Cardano.CLI.Read
import qualified Cardano.CLI.Run.Key as Key
import Cardano.CLI.Types.Common
import Cardano.CLI.Types.Errors.AddressCmdError
import Cardano.CLI.Types.Key (PaymentVerifier (..), StakeIdentifier (..),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ import qualified Cardano.CLI.EraBased.Commands.Governance.DRep as DRep
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.StakeAddress (runStakeAddressKeyGenCmd)
import qualified Cardano.CLI.IO.Lazy as Lazy
import qualified Cardano.CLI.Run.Key as Key
import Cardano.CLI.Run.Node (runNodeIssueOpCertCmd, runNodeKeyGenColdCmd,
runNodeKeyGenKesCmd, runNodeKeyGenVrfCmd)
import Cardano.CLI.Types.Common
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import Cardano.Api.Shelley

import Cardano.CLI.EraBased.Commands.Governance.Committee
import qualified Cardano.CLI.EraBased.Commands.Governance.Committee as Cmd
import qualified Cardano.CLI.EraBased.Run.Key as Key
import Cardano.CLI.Read (readVerificationKeySource)
import qualified Cardano.CLI.Run.Key as Key
import Cardano.CLI.Types.Errors.GovernanceCommitteeError
import Cardano.CLI.Types.Key.VerificationKey

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import qualified Cardano.Api.Ledger as L

import Cardano.CLI.EraBased.Commands.Governance.DRep (DRepHashGoal (..))
import qualified Cardano.CLI.EraBased.Commands.Governance.DRep as Cmd
import qualified Cardano.CLI.EraBased.Run.Key as Key
import Cardano.CLI.Run.Hash (allSchemas, getByteStringFromURL, httpsAndIpfsSchemas)
import qualified Cardano.CLI.Run.Key as Key
import Cardano.CLI.Types.Common
import Cardano.CLI.Types.Errors.CmdError
import Cardano.CLI.Types.Errors.GovernanceCmdError
Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/EraBased/Run/StakeAddress.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import qualified Cardano.Api.Ledger as L
import Cardano.Api.Shelley

import Cardano.CLI.EraBased.Commands.StakeAddress
import qualified Cardano.CLI.EraBased.Run.Key as Key
import Cardano.CLI.Read
import qualified Cardano.CLI.Run.Key as Key
import Cardano.CLI.Types.Common
import Cardano.CLI.Types.Errors.StakeAddressCmdError
import Cardano.CLI.Types.Errors.StakeAddressRegistrationError
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 @@ -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.Key
import Cardano.CLI.Options.Node
import Cardano.CLI.Options.Ping (parsePingCmd)
import Cardano.CLI.Render (customRenderHelp)
Expand Down Expand Up @@ -53,13 +54,17 @@ pref =
nodeCmdsTopLevel :: Parser ClientCommand
nodeCmdsTopLevel = NodeCommands <$> pNodeCmds

keyCmdsTopLevel :: Parser ClientCommand
keyCmdsTopLevel = KeyCommands <$> pKeyCmds

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.
[ nodeCmdsTopLevel
[ keyCmdsTopLevel
, nodeCmdsTopLevel
, parseLegacy envCli
, parseByron envCli
, parseAnyEra envCli
Expand Down
Loading

0 comments on commit 184b794

Please sign in to comment.