-
Notifications
You must be signed in to change notification settings - Fork 15
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
Add compatible command group #917
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
551385a
Implement Cardano.CLI.Compatible.Commands
Jimbo4350 2b50388
Add Cardano.CLI.Compatible.Governance
Jimbo4350 2c1c64e
Add Cardano.CLI.Compatible.Transaction
Jimbo4350 a0e22ce
Add Cardano.CLI.Compatible.Run
Jimbo4350 0089f28
Merge with Cardano.CLI.Compatible.Commands commit
Jimbo4350 0059f89
Update ClientCommandErrors and runClientCommand with new compatibility
Jimbo4350 f7b7384
Factor out renderAnyCmdError
Jimbo4350 cf9ca7f
Add compatible command group to the top level of cardano-cli
Jimbo4350 ec7e225
Move subParser
Jimbo4350 7c90658
Fix CI
Jimbo4350 7a3c09a
Add ability to submit votes
Jimbo4350 a23413f
Update golden files
Jimbo4350 e841a8d
Rebase changes
Jimbo4350 70c7079
Rebase changes
Jimbo4350 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
{-# LANGUAGE GADTs #-} | ||
{-# LANGUAGE LambdaCase #-} | ||
|
||
{- | ||
This module is concerned with providing backwards compatible cli commands for our internal | ||
testing needs. The intention is to restrict as much as possible which functionality we maintain backwards | ||
compatibility for. | ||
-} | ||
|
||
module Cardano.CLI.Compatible.Commands | ||
( AnyCompatibleCommand (..) | ||
, CompatibleCommand (..) | ||
, pAnyCompatibleCommand | ||
, renderAnyCompatibleCommand | ||
) | ||
where | ||
|
||
import Cardano.Api | ||
|
||
import Cardano.CLI.Compatible.Governance | ||
import Cardano.CLI.Compatible.Transaction | ||
import Cardano.CLI.Environment | ||
import Cardano.CLI.Parser | ||
|
||
import Data.Foldable | ||
import Data.Text | ||
import Options.Applicative | ||
import qualified Options.Applicative as Opt | ||
|
||
data AnyCompatibleCommand where | ||
AnyCompatibleCommand :: CompatibleCommand era -> AnyCompatibleCommand | ||
|
||
renderAnyCompatibleCommand :: AnyCompatibleCommand -> Text | ||
renderAnyCompatibleCommand = \case | ||
AnyCompatibleCommand cmd -> renderCompatibleCommand cmd | ||
|
||
data CompatibleCommand era | ||
= CompatibleTransactionCmd (CompatibleTransactionCmds era) | ||
| CompatibleGovernanceCmds (CompatibleGovernanceCmds era) | ||
|
||
renderCompatibleCommand :: CompatibleCommand era -> Text | ||
renderCompatibleCommand = \case | ||
CompatibleTransactionCmd cmd -> renderCompatibleTransactionCmd cmd | ||
CompatibleGovernanceCmds cmd -> renderCompatibleGovernanceCmds cmd | ||
|
||
pAnyCompatibleCommand :: EnvCli -> Parser AnyCompatibleCommand | ||
pAnyCompatibleCommand envCli = | ||
asum | ||
[ -- Note, byron is ommitted because there is already a legacy command group for it. | ||
subParser "shelley" $ | ||
Opt.info (AnyCompatibleCommand <$> pCompatibleCommand ShelleyBasedEraShelley envCli) $ | ||
Opt.progDesc "Shelley era commands" | ||
, subParser "allegra" $ | ||
Opt.info (AnyCompatibleCommand <$> pCompatibleCommand ShelleyBasedEraAllegra envCli) $ | ||
Opt.progDesc "Allegra era commands" | ||
, subParser "mary" $ | ||
Opt.info (AnyCompatibleCommand <$> pCompatibleCommand ShelleyBasedEraMary envCli) $ | ||
Opt.progDesc "Mary era commands" | ||
, subParser "alonzo" $ | ||
Opt.info (AnyCompatibleCommand <$> pCompatibleCommand ShelleyBasedEraAlonzo envCli) $ | ||
Opt.progDesc "Alonzo era commands" | ||
, subParser "babbage" $ | ||
Opt.info (AnyCompatibleCommand <$> pCompatibleCommand ShelleyBasedEraBabbage envCli) $ | ||
Opt.progDesc "Babbage era commands" | ||
, subParser "conway" $ | ||
Opt.info (AnyCompatibleCommand <$> pCompatibleCommand ShelleyBasedEraConway envCli) $ | ||
Opt.progDesc "Conway era commands" | ||
] | ||
|
||
pCompatibleCommand :: ShelleyBasedEra era -> EnvCli -> Parser (CompatibleCommand era) | ||
pCompatibleCommand era env = | ||
asum | ||
[ CompatibleTransactionCmd <$> pAllCompatibleTransactionCommands env era | ||
, CompatibleGovernanceCmds <$> pCompatibleGovernanceCmds era | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE LambdaCase #-} | ||
|
||
module Cardano.CLI.Compatible.Governance | ||
( CompatibleGovernanceCmds (..) | ||
, pCompatibleGovernanceCmds | ||
, renderCompatibleGovernanceCmds | ||
, runCompatibleGovernanceCmds | ||
) | ||
where | ||
|
||
import Cardano.Api | ||
|
||
import Cardano.CLI.EraBased.Options.Governance | ||
import Cardano.CLI.EraBased.Run.Governance | ||
import Cardano.CLI.Types.Errors.CmdError | ||
|
||
import Data.Foldable | ||
import Data.Maybe | ||
import Data.Text | ||
import Options.Applicative | ||
|
||
pCompatibleGovernanceCmds :: ShelleyBasedEra era -> Parser (CompatibleGovernanceCmds era) | ||
pCompatibleGovernanceCmds sbe = | ||
asum $ catMaybes [fmap CreateCompatibleProtocolUpdateCmd <$> pGovernanceCmds sbe] | ||
|
||
-- TODO: After QA confirmms that the new compatibility commands meet their needs | ||
-- we can remove all remaining legacy commands. We can also remove/move the exising | ||
-- byron era commands under the new compatiblilty commands. | ||
newtype CompatibleGovernanceCmds era | ||
= CreateCompatibleProtocolUpdateCmd (GovernanceCmds era) | ||
|
||
runCompatibleGovernanceCmds :: CompatibleGovernanceCmds era -> ExceptT CmdError IO () | ||
runCompatibleGovernanceCmds = \case | ||
CreateCompatibleProtocolUpdateCmd cmd -> runGovernanceCmds cmd | ||
|
||
renderCompatibleGovernanceCmds :: CompatibleGovernanceCmds era -> Text | ||
renderCompatibleGovernanceCmds = \case | ||
CreateCompatibleProtocolUpdateCmd cmd -> renderGovernanceCmds cmd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{-# LANGUAGE LambdaCase #-} | ||
|
||
module Cardano.CLI.Compatible.Run | ||
( CompatibleCmdError | ||
, renderCompatibleCmdError | ||
, runAnyCompatibleCommand | ||
, runCompatibleCommand | ||
) | ||
where | ||
|
||
import Cardano.Api | ||
|
||
import Cardano.CLI.Compatible.Commands | ||
import Cardano.CLI.Compatible.Governance | ||
import Cardano.CLI.Compatible.Transaction | ||
import Cardano.CLI.Render | ||
import Cardano.CLI.Types.Errors.CmdError | ||
|
||
import Data.Text (Text) | ||
|
||
data CompatibleCmdError | ||
= CompatibleTransactionError CompatibleTransactionError | ||
| CompatibleGovernanceError CmdError | ||
|
||
renderCompatibleCmdError :: Text -> CompatibleCmdError -> Doc ann | ||
renderCompatibleCmdError cmdText = \case | ||
CompatibleTransactionError e -> renderAnyCmdError cmdText prettyError e | ||
CompatibleGovernanceError e -> renderCmdError cmdText e | ||
|
||
runAnyCompatibleCommand :: AnyCompatibleCommand -> ExceptT CompatibleCmdError IO () | ||
runAnyCompatibleCommand (AnyCompatibleCommand cmd) = runCompatibleCommand cmd | ||
|
||
runCompatibleCommand :: CompatibleCommand era -> ExceptT CompatibleCmdError IO () | ||
runCompatibleCommand (CompatibleTransactionCmd txCmd) = | ||
firstExceptT CompatibleTransactionError $ runCompatibleTransactionCmd txCmd | ||
runCompatibleCommand (CompatibleGovernanceCmds govCmd) = | ||
firstExceptT CompatibleGovernanceError $ runCompatibleGovernanceCmds govCmd |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsers should go to
cardano-cli/src/Cardano/CLI/Compatible/Options/Common.hs
or something similarThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to mirror the previous
EraBased
directory structure. ACommon
module is fine but this parser is not common i.e it's called in one place.