Use Getopt.Symbol for options with a fixed list of choices, so there is
no need to check them on our own.
---
v2v/cmdline.ml | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/v2v/cmdline.ml b/v2v/cmdline.ml
index 2d0a10a..96e0509 100644
--- a/v2v/cmdline.ml
+++ b/v2v/cmdline.ml
@@ -83,8 +83,7 @@ let parse_cmdline () =
| "libvirt" -> input_mode := `Libvirt
| "libvirtxml" -> input_mode := `LibvirtXML
| "ova" -> input_mode := `OVA
- | s ->
- error (f_"unknown -i option: %s") s
+ | _ -> assert false (* Already checked by Getopt.Symbol. *)
in
let network_map = ref NetworkMap.empty in
@@ -125,8 +124,7 @@ let parse_cmdline () =
| "ovirt" | "rhev" -> output_mode := `RHEV
| "qemu" -> output_mode := `QEmu
| "vdsm" -> output_mode := `VDSM
- | s ->
- error (f_"unknown -o option: %s") s
+ | _ -> assert false (* Already checked by Getopt.Symbol. *)
in
let output_alloc = ref `Not_set in
@@ -136,8 +134,7 @@ let parse_cmdline () =
match mode with
| "sparse" -> output_alloc := `Sparse
| "preallocated" -> output_alloc := `Preallocated
- | s ->
- error (f_"unknown -oa option: %s") s
+ | _ -> assert false (* Already checked by Getopt.Symbol. *)
in
let root_choice = ref AskRoot in
@@ -171,7 +168,7 @@ let parse_cmdline () =
[ L"dcpath"; L"dcPath" ], Getopt.String ("path",
set_string_option_once "--dcpath" dcpath),
s_"Override dcPath (for vCenter)";
[ L"debug-overlay"; L"debug-overlays" ], Getopt.Set
debug_overlays, s_"Save overlay files";
- [ S 'i' ], Getopt.String (i_options, set_input_mode), s_"Set
input mode (default: libvirt)";
+ [ S 'i' ], Getopt.Symbol (i_options, Modules_list.input_modules
~with_alias:true (), set_input_mode), s_"Set input mode (default: libvirt)";
[ M"ic" ], Getopt.String ("uri", set_string_option_once
"-ic" input_conn),
s_"Libvirt URI";
[ M"if" ], Getopt.String ("format", set_string_option_once
"-if" input_format),
@@ -182,8 +179,8 @@ let parse_cmdline () =
[ L"no-copy" ], Getopt.Clear do_copy, s_"Just write the
metadata";
[ L"no-trim" ], Getopt.String ("-", no_trim_warning),
s_"Ignored for backwards
compatibility";
- [ S 'o' ], Getopt.String (o_options, set_output_mode), s_"Set
output mode (default: libvirt)";
- [ M"oa" ], Getopt.String ("sparse|preallocated",
set_output_alloc),
+ [ S 'o' ], Getopt.Symbol (o_options, Modules_list.output_modules
~with_alias:true (), set_output_mode), s_"Set output mode (default: libvirt)";
+ [ M"oa" ], Getopt.Symbol (s_"mode", [ "sparse";
"preallocated" ], set_output_alloc),
s_"Set output allocation mode";
[ M"oc" ], Getopt.String ("uri", set_string_option_once
"-oc" output_conn),
s_"Libvirt URI";
--
2.7.4