diff --git a/bench/cardano-topology/cardano-topology.cabal b/bench/cardano-topology/cardano-topology.cabal index 4de055fa26c..9d3a4883134 100644 --- a/bench/cardano-topology/cardano-topology.cabal +++ b/bench/cardano-topology/cardano-topology.cabal @@ -34,6 +34,6 @@ executable cardano-topology , bytestring , containers , graphviz - , optparse-applicative-fork + , optparse-applicative , split , text diff --git a/bench/locli/locli.cabal b/bench/locli/locli.cabal index bffad087b8e..49b47659c26 100644 --- a/bench/locli/locli.cabal +++ b/bench/locli/locli.cabal @@ -52,7 +52,7 @@ library , gnuplot , Histogram , iohk-monitoring - , optparse-applicative-fork + , optparse-applicative , optparse-generic , ouroboros-network , process @@ -94,7 +94,7 @@ executable locli build-depends: base , cardano-prelude , locli - , optparse-applicative-fork + , optparse-applicative , text , text-short , transformers diff --git a/bench/tx-generator/tx-generator.cabal b/bench/tx-generator/tx-generator.cabal index 90fb1aaa0d4..a63e791e84d 100644 --- a/bench/tx-generator/tx-generator.cabal +++ b/bench/tx-generator/tx-generator.cabal @@ -86,7 +86,7 @@ library , ixset-typed , network , network-mux - , optparse-applicative-fork + , optparse-applicative , ouroboros-consensus , ouroboros-consensus-byron , ouroboros-consensus-cardano @@ -139,7 +139,7 @@ test-suite tx-generator-test build-depends: base >=4.12 && <5 , hedgehog , heredoc - , optparse-applicative-fork + , optparse-applicative , tasty , tasty-hedgehog , tasty-hunit diff --git a/cabal.project b/cabal.project index 21dca0dfdd8..08c9cf5a7f1 100644 --- a/cabal.project +++ b/cabal.project @@ -107,12 +107,19 @@ package cardano-ledger-alonzo-test -- --------------------------- 8< -------------------------- -- Please do not put any `source-repository-package` clause above this line. +-- Using a fork until our patches can be merged upstream +source-repository-package + type: git + location: https://github.com/input-output-hk/criterion + tag: fb2e7be532db96255d203f86360230cae37130f3 + --sha256: 14r9zkfa8zslky3969gaq27gi7yi9rlqv0h1iq7zam9l15z53vhr + -- Using a fork until our patches can be merged upstream source-repository-package type: git location: https://github.com/input-output-hk/optparse-applicative - tag: 3b259646f60325a0759fdf10b129ddc23518d11a - --sha256: 110sis5l8xff9sgxvk49sad2j1i3nikfycf8ff0yfxmbj0vx3b3k + tag: 27b99b346d58db877a61224a745de872601ba3e6 + --sha256: 0y6imnwsd6h2myhaf6m1b8vyrnx44qz2s9x8760ii66jz15xih6r source-repository-package type: git diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index b29e20d933b..ea7409d6a55 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -125,7 +125,7 @@ library , formatting , iproute , network - , optparse-applicative-fork + , optparse-applicative , ouroboros-consensus , ouroboros-consensus-byron , ouroboros-consensus-cardano @@ -158,7 +158,7 @@ executable cardano-cli build-depends: cardano-cli , cardano-crypto-class , cardano-prelude - , optparse-applicative-fork + , optparse-applicative , transformers-except test-suite cardano-cli-test diff --git a/cardano-cli/src/Cardano/CLI/Render.hs b/cardano-cli/src/Cardano/CLI/Render.hs index 281ff561e97..67572565246 100644 --- a/cardano-cli/src/Cardano/CLI/Render.hs +++ b/cardano-cli/src/Cardano/CLI/Render.hs @@ -10,6 +10,7 @@ import Options.Applicative.Help.Types (helpText) import Prelude (String) import Prettyprinter import Prettyprinter.Render.Util.SimpleDocTree +import Options.Applicative.Help.Types (renderHelp) import qualified Data.Text as T import qualified System.Environment as IO @@ -26,7 +27,12 @@ cliHelpTraceEnabled = IO.unsafePerformIO $ do -- tools can be used to inspect tracing that aids in describing the structure of the output -- document. customRenderHelp :: Int -> ParserHelp -> String -customRenderHelp cols +customRenderHelp = if cliHelpTraceEnabled + then customRenderHelpAsHtml + else customRenderHelpAsAnsi + +customRenderHelpAsHtml :: Int -> ParserHelp -> String +customRenderHelpAsHtml cols = T.unpack . wrapper . renderSimplyDecorated id renderElement @@ -34,9 +40,10 @@ customRenderHelp cols . layoutSmart (LayoutOptions (AvailablePerLine cols 1.0)) . helpText where - renderElement = if cliHelpTraceEnabled - then \(AnnTrace _ name) x -> "" <> x <> "" - else flip const + renderElement :: Ann -> Text -> Text + renderElement ann x = case ann of + AnnTrace _ name -> "" <> x <> "" + AnnStyle _ -> x wrapper = if cliHelpTraceEnabled then id . ("\n" <>) @@ -46,3 +53,6 @@ customRenderHelp cols . (<> "\n") . (<> "\n") else id + +customRenderHelpAsAnsi :: Int -> ParserHelp -> String +customRenderHelpAsAnsi = renderHelp diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs b/cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs index f63803e92ef..09e4a6c30ab 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs @@ -48,6 +48,7 @@ import qualified Data.Aeson as Aeson import qualified Data.Aeson.Parser as Aeson.Parser import qualified Data.Attoparsec.ByteString.Char8 as Atto import qualified Options.Applicative as Opt +import qualified Options.Applicative.Help as H import qualified Text.Parsec as Parsec import qualified Text.Parsec.Error as Parsec import qualified Text.Parsec.Language as Parsec @@ -558,17 +559,25 @@ pTransaction :: Parser TransactionCmd pTransaction = asum [ subParser "build-raw" - $ Opt.info pTransactionBuildRaw $ Opt.progDescDoc $ Just $ - pretty @String "Build a transaction (low-level, inconvenient)" - <> line <> line - <> "Please note the order of some cmd options is crucial. If used incorrectly may produce " - <> "undesired tx body. See nested [] notation above for details." + $ Opt.info pTransactionBuildRaw $ Opt.progDescDoc $ Just $ mconcat + [ pretty @String "Build a transaction (low-level, inconvenient)" + , line + , line + , H.yellow $ 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." + ] + ] , subParser "build" - $ Opt.info pTransactionBuild $ Opt.progDescDoc $ Just $ - pretty @String "Build a balanced transaction (automatically calculates fees)" - <> line <> line - <> "Please note the order of some cmd options is crucial. If used incorrectly may produce " - <> "undesired tx body. See nested [] notation above for details." + $ Opt.info pTransactionBuild $ Opt.progDescDoc $ Just $ mconcat + [ pretty @String "Build a balanced transaction (automatically calculates fees)" + , line + , line + , H.yellow $ 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." + ] + ] , subParser "sign" (Opt.info pTransactionSign $ Opt.progDesc "Sign a transaction") , subParser "witness" diff --git a/cardano-node-chairman/cardano-node-chairman.cabal b/cardano-node-chairman/cardano-node-chairman.cabal index 9c343654be3..a8589bda3de 100644 --- a/cardano-node-chairman/cardano-node-chairman.cabal +++ b/cardano-node-chairman/cardano-node-chairman.cabal @@ -48,7 +48,7 @@ executable cardano-node-chairman , contra-tracer , io-classes , network-mux - , optparse-applicative-fork + , optparse-applicative , ouroboros-consensus , ouroboros-network , ouroboros-network-framework diff --git a/cardano-node/cardano-node.cabal b/cardano-node/cardano-node.cabal index da59e1e40ee..5b566e0353d 100644 --- a/cardano-node/cardano-node.cabal +++ b/cardano-node/cardano-node.cabal @@ -129,7 +129,7 @@ library , network , network-mux , nothunks - , optparse-applicative-fork + , optparse-applicative , ouroboros-consensus , ouroboros-consensus-byron , ouroboros-consensus-cardano @@ -167,7 +167,7 @@ executable cardano-node build-depends: cardano-config , cardano-node , cardano-prelude - , optparse-applicative-fork + , optparse-applicative , text test-suite cardano-node-test diff --git a/cardano-submit-api/cardano-submit-api.cabal b/cardano-submit-api/cardano-submit-api.cabal index 9e9412a5831..67d913a165a 100644 --- a/cardano-submit-api/cardano-submit-api.cabal +++ b/cardano-submit-api/cardano-submit-api.cabal @@ -31,7 +31,7 @@ common http-media { build-depends: http-media common iohk-monitoring { build-depends: iohk-monitoring >= 0.1.10.1 } common mtl { build-depends: mtl >= 2.2.2 } common network { build-depends: network >= 3.1.2.1 } -common optparse-applicative-fork { build-depends: optparse-applicative-fork >= 0.16.1.0 } +common optparse-applicative { build-depends: optparse-applicative >= 0.16.1.0 } common ouroboros-consensus-cardano { build-depends: ouroboros-consensus-cardano >= 0.1.0.0 } common ouroboros-network { build-depends: ouroboros-network >= 0.1.0.0 } common prometheus { build-depends: prometheus >= 2.2.2 } @@ -78,7 +78,7 @@ library , iohk-monitoring , mtl , network - , optparse-applicative-fork + , optparse-applicative , ouroboros-consensus-cardano , ouroboros-network , prometheus @@ -111,7 +111,7 @@ library executable cardano-submit-api import: base, project-config , cardano-submit-api - , optparse-applicative-fork + , optparse-applicative main-is: Main.hs hs-source-dirs: app ghc-options: -threaded -rtsopts "-with-rtsopts=-T -I0" diff --git a/cardano-testnet/cardano-testnet.cabal b/cardano-testnet/cardano-testnet.cabal index b45c4a37d3e..3e503e4c8fc 100644 --- a/cardano-testnet/cardano-testnet.cabal +++ b/cardano-testnet/cardano-testnet.cabal @@ -74,7 +74,7 @@ executable cardano-testnet , cardano-testnet , hedgehog , hedgehog-extras - , optparse-applicative-fork + , optparse-applicative , resourcet , stm , text