From 79dc587eccb558fe6a45a2e4682d42a2d1b94627 Mon Sep 17 00:00:00 2001 From: Jan Mas Rovira Date: Tue, 24 Dec 2024 11:31:56 +0100 Subject: [PATCH] improve help message --- .../Dev/Anoma/Prove/Options/ProveArg.hs | 2 +- .../Dev/Anoma/Prove/Options/ProveArgTag.hs | 19 ++++++++++++++----- app/CommonOptions.hs | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/Commands/Dev/Anoma/Prove/Options/ProveArg.hs b/app/Commands/Dev/Anoma/Prove/Options/ProveArg.hs index dac53128c7..e2273396e7 100644 --- a/app/Commands/Dev/Anoma/Prove/Options/ProveArg.hs +++ b/app/Commands/Dev/Anoma/Prove/Options/ProveArg.hs @@ -38,7 +38,7 @@ parseProveArg' = ( long "arg" <> completer (listCompleter [show a <> ":" | a <- allElements @ProveArgTag]) <> metavar "ARG_TYPE:ARG" - <> helpDoc ("An argument to the program." <> line <> enumHelp @ProveArgTag proveArgTagHelp) + <> helpDoc ("An argument to the program:" <> line <> proveArgTagHelp) ) where pProveArgTag :: Parse ProveArgTag diff --git a/app/Commands/Dev/Anoma/Prove/Options/ProveArgTag.hs b/app/Commands/Dev/Anoma/Prove/Options/ProveArgTag.hs index 0ecd46bb4b..87cb171f82 100644 --- a/app/Commands/Dev/Anoma/Prove/Options/ProveArgTag.hs +++ b/app/Commands/Dev/Anoma/Prove/Options/ProveArgTag.hs @@ -26,8 +26,17 @@ type family ProveArgType s = res where $(genDefunSymbols [''ProveArgType]) $(genSingletons [''ProveArgTag]) -proveArgTagHelp :: ProveArgTag -> AnsiDoc -proveArgTagHelp = \case - ProveArgTagNat -> "A natural number that is passed verbatim as a nockma atom" - ProveArgTagBase64 -> "A path to a file with a base64 encoded nockma atom" - ProveArgTagBytes -> "A path to a file with a byte encoded nockma atom" +proveArgTagHelp :: AnsiDoc +proveArgTagHelp = itemize (tagHelp <$> allElements) + where + tagHelp :: ProveArgTag -> AnsiDoc + tagHelp t = + let mvar, explain :: AnsiDoc + (mvar, explain) = first sty $ case t of + ProveArgTagNat -> ("NATURAL", "is passed verbatim as a nockma atom") + ProveArgTagBase64 -> ("FILE", "is a file with a base64 encoded nockma atom") + ProveArgTagBytes -> ("FILE", "is a file with a byte encoded nockma atom") + sty = annotate (bold <> colorDull Blue) + tagvar :: AnsiDoc + tagvar = sty (show t <> ":" <> mvar) + in tagvar <+> "where" <+> mvar <+> explain diff --git a/app/CommonOptions.hs b/app/CommonOptions.hs index c68feb1a1e..3df1922c62 100644 --- a/app/CommonOptions.hs +++ b/app/CommonOptions.hs @@ -234,7 +234,7 @@ fieldSizeOpt = eitherReader aux | otherwise = Left $ Prelude.show n <> " is not a recognized field size" enumHelp :: forall a. (Bounded a, Enum a, Show a) => (a -> AnsiDoc) -> AnsiDoc -enumHelp showHelp = vsep ["• " <> annotate bold (show x) <> ": " <> showHelp x | x <- allElements] +enumHelp showHelp = itemize [annotate bold (show x) <> ": " <> showHelp x | x <- allElements] enumReader :: forall a. (Bounded a, Enum a, Show a) => Proxy a -> ReadM a enumReader _ = eitherReader $ \val ->