Command-line arguments: Difference between revisions
m
→Using the Arg module: update link/formatting
m (Improve shell code for calling a lang program) |
m (→Using the Arg module: update link/formatting) |
||
Line 1,810:
done</syntaxhighlight>
=== Using the [
<syntaxhighlight lang="ocaml">(* default values *)
let somebool = ref false
Line 1,831 ⟶ 1,830:
(fun x -> raise (Arg.Bad ("Bad argument : " ^ x)))
usage;
<pre>
--help Display this list of options
▲ Printf.printf " %b %d '%s'\n" !somebool !someint !somestr;
false 0 ''
▲ usage: tmp.ml [-b] [-s string] [-d int]
</pre>
▲ -b : set somebool to true
▲ -s : what follows -s sets some string
▲ -d : some int parameter
▲ --help Display this list of options
▲ % ocaml arg.ml -d 4 -b -s blabla
▲ true 4 'blabla'
▲ % ocaml arg.ml
=={{header|Odin}}==
|