+
+ (* Construct the argspec.
+ * May include extra arguments specified by the tool.
+ *)
+ let argspec =
+ let extra_args = match tool with
+ | None -> []
+ | Some (_, _, _, _, extra_args, _, _, _) -> extra_args in
+ let argspec = [
+ "-A", Arg.String set_architecture,
+ "arch " ^ s_"Set kernel architecture, endianness and word size";
+ "-E", Arg.String set_endian,
+ "endian " ^ s_"Set kernel endianness";
+ "-T", Arg.String set_text_addr,
+ "addr " ^ s_"Set kernel text address";
+ "-W", Arg.String set_wordsize,
+ "addr " ^ s_"Set kernel word size";
+ "-c", Arg.Set_string uri,
+ "uri " ^ s_ "Connect to URI";
+ "--connect", Arg.Set_string uri,
+ "uri " ^ s_ "Connect to URI";
+ "--debug", Arg.Set debug,
+ " " ^ s_"Debug mode (default: false)";
+ "-t", Arg.String memory_image,
+ "image " ^ s_"Use saved kernel memory image";
+ "--version", Arg.Unit version,
+ " " ^ s_"Display version and exit";
+ ] @ extra_args in
+
+ (* Sort options alphabetically on first alpha character. *)
+ let cmp (a,_,_) (b,_,_) =
+ let chars = "-" in
+ let a = String.strip ~chars a and b = String.strip ~chars b in
+ compare a b
+ in
+ let argspec = List.sort ~cmp argspec in
+ (* Make the options line up nicely. *)
+ Arg.align argspec in
+
+ (* Parse the command line. This will exit if --version or --help found. *)