diff options
Diffstat (limited to 'src/wallgen.ml')
-rw-r--r-- | src/wallgen.ml | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/src/wallgen.ml b/src/wallgen.ml index c27f0eb..240fbc4 100644 --- a/src/wallgen.ml +++ b/src/wallgen.ml @@ -18,25 +18,31 @@ let anon_fun item = let input_immediate items = - if Array.length !input_seq > 0 - then (prerr_endline "Error: Multiple input sequences specified"; exit 2) - else try input_seq := Util.read_integer_list items + if Array.length !input_seq > 0 then + (prerr_endline "Error: Multiple input sequences specified"; + exit 2) + else + try input_seq := Util.read_integer_list items with Util.Not_an_integer s -> prerr_endline ("Error: The argument '" ^ s ^ "' is not an integer"); exit 2 let input_from_file filename = - if Array.length !input_seq > 0 - then (prerr_endline "Error: Multiple input sequences specified"; exit 2) - else try input_seq := Util.read_sequence_file filename + if Array.length !input_seq > 0 then + (prerr_endline "Error: Multiple input sequences specified"; + exit 2) + else + try input_seq := Util.read_sequence_file filename with Util.Not_an_integer s -> prerr_endline ("Error: The item '" ^ s ^ "' from file '" ^ filename ^ "' is not an integer"); exit 2 let use_random len = - if Array.length !input_seq > 0 - then (prerr_endline "Error: Multiple input sequences specified"; exit 2) - else input_seq := Sequence.random ~len + if Array.length !input_seq > 0 then + (prerr_endline "Error: Multiple input sequences specified"; + exit 2) + else + input_seq := Sequence.random ~len @@ -65,14 +71,22 @@ module My_Wall = Wall.Make (My_Algebra) let _ = - if Array.length Sys.argv <= 1 then (Arg.usage speclist usage_msg; exit 1); + if Array.length Sys.argv <= 1 then + (Arg.usage speclist usage_msg; + exit 1); + Arg.parse speclist anon_fun usage_msg; - if Array.length !input_seq = 0 then (prerr_endline "Error: No input sequence provided"; exit 2); - let result = My_Wall.create - ~dimx:(Array.length !input_seq) - ~dimy:!depth_limit - ~init:!input_seq in + if Array.length !input_seq = 0 then + (prerr_endline "Error: No input sequence provided"; + exit 2); + + let result = + My_Wall.create + ~dimx:(Array.length !input_seq) + ~dimy:!depth_limit + ~init:!input_seq in + My_Wall.print result |