-
Notifications
You must be signed in to change notification settings - Fork 75
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
Adding an Examples
section for --help
#251
Comments
As far as I'm aware no such mechanism exists, but supporting it does seem like a useful addition One factor is that any level in the hierarchy of subcommands could potentially have examples. Don't have an idea off the top of my head as to how to incorporate it, i.e. whether a function would need to be supplied into the parse and/or render help functions, or whether something basic like checking the Best place to start is in the tests - they're effectively the reference section of the manual in terms of how to do stuff not explicitly called out in the tutorial. (Assuming you can some up with a clean enough extension point that meets your needs, the idea does seem to make sense...) |
Thank you foe the answer. For now I ended up doing this: let examples = """
EXAMPLE 1
lorem ipsum dolor sit amet
"""
type CustomErrorHandler() =
interface IExiter with
member __.Name = "Exiter"
member __.Exit (msg, code) =
if code = ErrorCode.HelpText then
printfn "%s" msg
printfn "%s" examples
exit 0
else
(ProcessExiter() :> IExiter).Exit(msg, code)
[<EntryPoint>]
let main argv =
let parser = ArgumentParser.Create<CliArguments>(programName = "myTool", errorHandler = CustomErrorHandler())
let results = parser.Parse argv
... |
Nice solution - I think it makes sense to keep the issue open for now as it would be nice for it to be first class in some way as examples are definitely a thing I know my tools could benefit from (a big improvement on putting it in my already-too-long READMEs!) |
Is it possible for
argu
to print anExamples
section when asked for--help
?The text was updated successfully, but these errors were encountered: