(************************************************************ arg_test.ml Created : Mon Nov 4 11:27:21 2002 Last modified: Mon Nov 04 19:49:16 2002 Compile: ocamlopt.opt arg_test.ml -o arg_test # FTP Directory: sources/ocaml # ************************************************************) (** Getoptだけじゃない。Argモジュールで引数処理をできるようだ @author Takashi Masuyama *) let is_grouping = ref true (** オプション文字列, オプション処理関数 (Arg.spec 典型的なものが揃っている), 説明文字列のtoupleで一つのオプションを設定する。説明は -help オプション を指定すると表示される。 *) let specs = [ ("-n", Arg.Clear(is_grouping),"Not group"); ("-u", Arg.Unit(fun () -> print_endline "hello"), "Print this message?") ] let _ = Arg.parse specs (fun x -> Printf.printf "File: %s\n" x) "usage:"; Printf.printf "is_grouping %b\n" !is_grouping