Commit 559a6d39 authored by Kim Nguyễn's avatar Kim Nguyễn
Browse files

Align command-line options.

parent 4ef65a3d
open Cduce_core
let out_dir = ref [] (* directory of the output file *)
let src = ref []
......@@ -24,52 +25,76 @@ let version () =
(Cduce_config.descrs ());
exit 0
let specs =
[
("--compile", Arg.Set compile, "compile the given CDuce file");
("-c", Arg.Set compile, " same as --compile");
("--run", Arg.Set run, " execute the given .cdo files");
( "--verbose",
Arg.Set Cduce_driver.verbose,
"(for --compile) show types of exported values" );
( "--obj-dir",
Arg.String (fun s -> out_dir := s :: !out_dir),
"(for --compile) directory for the compiled .cdo file" );
( "-I",
Arg.String (fun s -> Cduce_loc.obj_path := s :: !Cduce_loc.obj_path),
" add one directory to the lookup path for .cdo/.cmi and include \
files" );
( "--stdin",
Arg.Unit (fun () -> src := "" :: !src),
" read CDuce script on standard input" );
( "--arg",
Arg.Rest (fun s -> args := s :: !args),
" following arguments are passed to the CDuce program" );
( "--script",
Arg.Rest
(fun s ->
if not !script then (
script := true;
src := s :: !src )
else args := s :: !args),
" the first argument after is the source, then the arguments" );
( "--no",
Arg.String Cduce_config.inhibit,
" disable a feature (cduce -v to get a list of features)" );
( "--debug",
Arg.Unit (fun () -> Stats.set_verbosity Stats.Summary),
" print profiling/debugging information" );
( "-v",
Arg.Unit version,
" print CDuce version, and list built-in optional features" );
( "--version",
Arg.Unit version,
"print CDuce version, and list built-in optional features" );
("--mlstub", Arg.Set mlstub, " produce stub ML code from a compiled unit");
( "--topstub",
Arg.Set topstub,
"produce stub ML code for a toplevel from a primitive file" );
]
let parse_argv () =
let usage_msg =
"Usage:\ncduce [OPTIONS ...] [FILE ...] [--arg argument ...]\n\nOptions:"
in
let help = ref (fun () -> assert false) in
let specs =
Arg.align
( [
("--compile", Arg.Set compile, " compile the given CDuce file");
("-c", Arg.Set compile, " same as --compile");
("--run", Arg.Set run, " execute the given .cdo files");
( "--verbose",
Arg.Set Cduce_driver.verbose,
" show types of exported values (for --compile)" );
( "--obj-dir",
Arg.String (fun s -> out_dir := s :: !out_dir),
" directory for the compiled .cdo file (for --compile)" );
( "-I",
Arg.String (fun s -> Cduce_loc.obj_path := s :: !Cduce_loc.obj_path),
" add one directory to the lookup path for .cdo/.cmi and include \
files" );
( "--stdin",
Arg.Unit (fun () -> src := "" :: !src),
" read CDuce script on standard input" );
( "--arg",
Arg.Rest (fun s -> args := s :: !args),
" following arguments are passed to the CDuce program" );
( "--script",
Arg.Rest
(fun s ->
if not !script then (
script := true;
src := s :: !src )
else args := s :: !args),
" the first argument after is the source, then the arguments" );
( "--no",
Arg.String Cduce_config.inhibit,
" disable a feature (cduce -v to get a list of features)" );
( "--debug",
Arg.Unit (fun () -> Stats.set_verbosity Stats.Summary),
" print profiling/debugging information" );
( "-v",
Arg.Unit version,
" print CDuce version, and list built-in optional features" );
( "--version",
Arg.Unit version,
" print CDuce version, and list built-in optional features" );
( "--mlstub",
Arg.Set mlstub,
" produce stub ML code from a compiled unit" );
( "--topstub",
Arg.Set topstub,
" produce stub ML code for a toplevel from a primitive file" );
( "-help",
Arg.Unit (fun () -> raise (Arg.Bad "unknown option '-help'")),
"" );
]
@ !Cduce_driver.extra_specs
@ [
("-h", Arg.Unit (fun () -> !help ()), " display this list of options");
( "--help",
Arg.Unit (fun () -> !help ()),
" display this list of options" );
] )
in
(help :=
fun () ->
Arg.usage specs usage_msg;
exit 0);
Arg.parse specs (fun s -> src := s :: !src) usage_msg
let ppf = Format.std_formatter
......@@ -80,10 +105,7 @@ let err s =
exit 1
let mode () =
Arg.parse
(specs @ !Cduce_driver.extra_specs)
(fun s -> src := s :: !src)
"Usage:\ncduce [OPTIONS ...] [FILE ...] [--arg argument ...]\n\nOptions:";
parse_argv ();
if !mlstub then
match !src with
| [ x ] -> `Mlstub x
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment