2 * Copyright (C) 2010 Red Hat Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 | Open_guest of string
26 | Open_images of (string * string option) list
32 let set_connect = function
33 | "" -> set_connect_uri None
34 | uri -> set_connect_uri (Some uri)
35 let set_format = function
36 | "" -> format := None
37 | f -> format := Some f
39 images := (image, !format) :: !images
41 guests := guest :: !guests
43 (* Parse command line arguments. *)
44 let argspec = Arg.align [
45 "-a", Arg.String add_image, "image Open disk image";
46 "--add", Arg.String add_image, "image Open disk image";
47 "-c", Arg.String set_connect, "uri Connect to libvirt URI";
48 "--connect", Arg.String set_connect, "uri Connect to libvirt URI";
49 "-d", Arg.String add_guest, "guest Open libvirt guest";
50 "--domain", Arg.String add_guest, "guest Open libvirt guest";
51 "--format", Arg.String set_format, "format Set format";
52 "-v", Arg.Unit set_verbose_flag, " Enable debugging messages";
53 "--verbose", Arg.Unit set_verbose_flag, " Enable debugging messages";
54 "-V", Arg.Unit set_verbose_flag, " Display version and exit";
55 "--version", Arg.Unit set_verbose_flag, " Display version and exit";
56 "-x", Arg.Unit set_trace_flag, " Enable tracing of libguestfs calls";
59 let prog = Filename.basename Sys.executable_name
62 raise (Arg.Bad "unknown argument")
66 %s: graphical guest filesystem browser
70 Open the program with an empty window.
72 %s -a disk.img [-a disk.img [...]]
73 Start with a guest from a disk image file.
76 Start with the named libvirt guest.
82 Arg.parse argspec anon_fun usage_msg;
84 (* Verify number of -a and -d options given on the command line. *)
85 let images = List.rev !images in
86 let guests = List.rev !guests in
88 match images, guests with
89 | [], [] -> Empty_window
90 | _, [] -> Open_images images
91 | [], [guest] -> Open_guest guest
93 failwith "cannot use -d option more than once"
95 failwith "cannot mix -a and -d options"