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

Depend on optparse-applicative instead of optparse-applicative-fork #899

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 8 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,11 @@ write-ghc-environment-files: always
-- IMPORTANT
-- Do NOT add more source-repository-package stanzas here unless they are strictly
-- temporary! Please read the section in CONTRIBUTING about updating dependencies.

package optparse-applicative
ghc-options: -Wno-x-partial -Wno-unused-imports

source-repository-package
type: git
location: https://github.com/smelc/optparse-applicative
tag: 1aad1773bc78e161083e8306dc9111ce515bb0ac
5 changes: 2 additions & 3 deletions cardano-cli/cardano-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ library
Cardano.CLI.Orphans
Cardano.CLI.Parser
Cardano.CLI.Read
Cardano.CLI.Render
Cardano.CLI.Run
Cardano.CLI.Run.Address
Cardano.CLI.Run.Address.Info
Expand Down Expand Up @@ -229,7 +228,7 @@ library
mtl,
network,
network-uri,
optparse-applicative-fork,
optparse-applicative,
ouroboros-consensus ^>=0.21,
ouroboros-consensus-cardano ^>=0.20,
ouroboros-consensus-protocol ^>=0.9.0.2,
Expand Down Expand Up @@ -263,7 +262,7 @@ executable cardano-cli
cardano-api,
cardano-cli,
cardano-crypto-class ^>=2.1.2,
optparse-applicative-fork,
optparse-applicative,
transformers-except,

library cardano-cli-test-lib
Expand Down
12 changes: 10 additions & 2 deletions cardano-cli/src/Cardano/CLI/Compatible/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ 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)
Expand All @@ -24,8 +23,17 @@ data CompatibleCmdError

renderCompatibleCmdError :: Text -> CompatibleCmdError -> Doc ann
renderCompatibleCmdError cmdText = \case
CompatibleTransactionError e -> renderAnyCmdError cmdText prettyError e
CompatibleTransactionError e -> renderAnyCmdError prettyError e
CompatibleGovernanceError e -> renderCmdError cmdText e
where
renderAnyCmdError :: (a -> Doc ann) -> a -> Doc ann
renderAnyCmdError renderer shelCliCmdErr =
mconcat
[ "Command failed: "
, pretty cmdText
, " Error: "
, renderer shelCliCmdErr
]

runAnyCompatibleCommand :: AnyCompatibleCommand -> ExceptT CompatibleCmdError IO ()
runAnyCompatibleCommand (AnyCompatibleCommand cmd) = runCompatibleCommand cmd
Expand Down
40 changes: 18 additions & 22 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import Cardano.CLI.Types.Common
import Data.Foldable
import Options.Applicative hiding (help, str)
import qualified Options.Applicative as Opt
import qualified Options.Applicative.Help as H
import Prettyprinter (line)

{- HLINT ignore "Use <$>" -}
Expand Down Expand Up @@ -49,13 +48,12 @@ pTransactionCmds era' envCli =
[ pretty @String "Build a transaction (low-level, inconvenient)"
, line
, line
, H.yellow $
mconcat
[ "Please note "
, H.underline "the order"
, " of some cmd options is crucial. If used incorrectly may produce "
, "undesired tx body. See nested [] notation above for details."
]
, mconcat
[ "Please note "
, "the order"
, " of some cmd options is crucial. If used incorrectly may produce "
, "undesired tx body. See nested [] notation above for details."
]
]
, pTransactionBuildCmd era' envCli
, forShelleyBasedEraInEon era' Nothing (`pTransactionBuildEstimateCmd` envCli)
Expand Down Expand Up @@ -157,13 +155,12 @@ pTransactionBuildCmd sbe envCli = do
[ pretty @String "Build a balanced transaction (automatically calculates fees)"
, line
, line
, H.yellow $
mconcat
[ "Please note "
, H.underline "the order"
, " of some cmd options is crucial. If used incorrectly may produce "
, "undesired tx body. See nested [] notation above for details."
]
, mconcat
[ "Please note "
, "the order"
, " of some cmd options is crucial. If used incorrectly may produce "
, "undesired tx body. See nested [] notation above for details."
]
]
where
pCmd era' = do
Expand Down Expand Up @@ -216,13 +213,12 @@ pTransactionBuildEstimateCmd eon' _envCli = do
"Build a balanced transaction without access to a live node (automatically estimates fees)"
, line
, line
, H.yellow $
mconcat
[ "Please note "
, H.underline "the order"
, " of some cmd options is crucial. If used incorrectly may produce "
, "undesired tx body. See nested [] notation above for details."
]
, mconcat
[ "Please note "
, "the order"
, " of some cmd options is crucial. If used incorrectly may produce "
, "undesired tx body. See nested [] notation above for details."
]
]
where
pCmd :: Exp.Era era -> Parser (TransactionCmds era)
Expand Down
5 changes: 1 addition & 4 deletions cardano-cli/src/Cardano/CLI/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ import Cardano.CLI.Options.Key
import Cardano.CLI.Options.Node
import Cardano.CLI.Options.Ping (parsePingCmd)
import Cardano.CLI.Parser
import Cardano.CLI.Render (customRenderHelp)
import Cardano.CLI.Run (ClientCommand (..))

import Data.Foldable
import Options.Applicative
import qualified Options.Applicative as Opt
import qualified Prettyprinter as PP

opts :: EnvCli -> ParserInfo ClientCommand
opts envCli =
Expand All @@ -49,8 +47,7 @@ pref =
Opt.prefs $
mconcat
[ showHelpOnEmpty
, helpEmbedBriefDesc PP.align
, helpRenderHelp customRenderHelp
, Opt.briefHangPoint maxBound
]

addressCmdsTopLevel :: EnvCli -> Parser ClientCommand
Expand Down
75 changes: 0 additions & 75 deletions cardano-cli/src/Cardano/CLI/Render.hs

This file was deleted.

4 changes: 2 additions & 2 deletions cardano-cli/src/Cardano/CLI/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import Cardano.CLI.EraBased.Run
import Cardano.CLI.EraBased.Run.Query
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)
Expand All @@ -47,6 +46,7 @@ import qualified Data.Text as Text
import qualified Data.Text.IO as Text
import Data.Version (showVersion)
import Options.Applicative.Help.Core
import Options.Applicative.Help.Types (renderHelp)
import Options.Applicative.Types (OptReader (..), Option (..), Parser (..),
ParserInfo (..), ParserPrefs (..))
import System.Info (arch, compilerName, compilerVersion, os)
Expand Down Expand Up @@ -145,7 +145,7 @@ runDisplayVersion = do

helpAll :: ParserPrefs -> String -> [String] -> ParserInfo a -> IO ()
helpAll pprefs progn rnames parserInfo = do
IO.putStrLn $ customRenderHelp 80 (usage_help parserInfo)
IO.putStrLn $ renderHelp 80 (usage_help parserInfo)
IO.putStrLn ""
go (infoParser parserInfo)
where
Expand Down
9 changes: 7 additions & 2 deletions cardano-cli/src/Cardano/CLI/Types/Errors/CmdError.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ where

import Cardano.Api

import Cardano.CLI.Render
import Cardano.CLI.Types.Errors.AddressCmdError
import Cardano.CLI.Types.Errors.DelegationError
import Cardano.CLI.Types.Errors.GenesisCmdError
Expand Down Expand Up @@ -66,4 +65,10 @@ renderCmdError cmdText = \case
CmdTransactionError e -> renderError renderTxCmdError e
where
renderError :: (a -> Doc ann) -> a -> Doc ann
renderError = renderAnyCmdError cmdText
renderError renderer shelCliCmdErr =
mconcat
[ "Command failed: "
, pretty cmdText
, " Error: "
, renderer shelCliCmdErr
]
Loading
Loading