Parse command-line arguments: Difference between revisions
Content added Content deleted
(Added nim implementation.) |
|||
Line 267: | Line 267: | ||
Other concepts are also possible... |
Other concepts are also possible... |
||
=={{header|Julia}}== |
|||
{{works with|Julia|0.6}} |
|||
Example taken from the official documentation of [https://carlobaldassi.github.io/ArgParse.jl/stable/ ArgParse docs]. |
|||
<lang julia>using ArgParse |
|||
function parse_commandline() |
|||
s = ArgParseSettings() |
|||
@add_arg_table s begin |
|||
"--opt1" |
|||
help = "an option with an argument" |
|||
"--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()</lang> |
|||
=={{header|Kotlin}}== |
=={{header|Kotlin}}== |