Skip to content

Commit

Permalink
improve help message
Browse files Browse the repository at this point in the history
  • Loading branch information
janmasrovira committed Dec 24, 2024
1 parent 74c4761 commit 79dc587
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/Commands/Dev/Anoma/Prove/Options/ProveArg.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 14 additions & 5 deletions app/Commands/Dev/Anoma/Prove/Options/ProveArgTag.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion app/CommonOptions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down

0 comments on commit 79dc587

Please sign in to comment.