Julia lets you include some Markdown syntax in docstrings, and renders it with nice colors in the terminal, e.g. in interactive help:
Is it possible to achieve the same with ArgParse.jl?
If you type Markdown into the help text, it just renders as plain text (try julia main.jl --help
with the file below).
`main.jl`
using ArgParse
using Markdown
function parse_commandline()
s = ArgParseSettings()
@add_arg_table! s begin
"--opt1"
help = "an option with an argument `and some markdown`"
"--opt2", "-o"
help = "another option with an argument"
arg_type = Int
default = 0
"--flag1"
help = "an option without argument, i.e. a flag"
action = :store_true
"arg1"
help = "a positional argument"
required = true
end
return parse_args(s)
end
function main()
parsed_args = parse_commandline()
println("Parsed args:")
for (arg,val) in parsed_args
println(" $arg => $val")
end
end
main()
And if you change the help strings to a md"markdown string"
(after using Markdown
) you get:
> julia main.jl --help
ERROR: LoadError: ArgParseSettingsError("help must be an AbstractString")