Files
libguestfs/generator/generator_optgroups.ml
Richard W.M. Jones 39d1a7dbc9 generator: Use a struct instead of a tuple to describe each action.
Each action changes from a tuple like this:

  ("cat", (RString "content", [Pathname "path"], []), 4,
   [ProtocolLimitWarning],
   [InitISOFS, Always, TestOutput (
      [["cat"; "/known-2"]], "abcdef\n")],
   "list the contents of a file",
   "[...]");

to a slightly longer but more readable struct:

  { defaults with
    name = "cat";
    style = RString "content", [Pathname "path"], [];
    proc_nr = Some 4;
    protocol_limit_warning = true;
    tests = [
      InitISOFS, Always, TestOutput (
      [["cat"; "/known-2"]], "abcdef\n")
    ];
    shortdesc = "list the contents of a file";
    longdesc = "[...]" };

["defaults" is a struct which contains the defaults for every field,
allowing us to use the "{ defaults with ... }" syntax to just update
the fields we want to be different from the defaults.]

This is a mechanical change and there is no change to the output of
the generator.  I checked the output before and after with diff to
verify this.  There are no changes in the output apart from UUIDs
which are expected to change with each run.
2012-07-11 19:55:16 +01:00

40 lines
1.4 KiB
OCaml

(* libguestfs
* Copyright (C) 2009-2012 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*)
(* Please read generator/README first. *)
open Generator_types
open Generator_actions
(* Create list of optional groups. *)
let optgroups =
let h = Hashtbl.create 13 in
List.iter (
function
| { name = name; optional = Some group } ->
let names = try Hashtbl.find h group with Not_found -> [] in
Hashtbl.replace h group (name :: names)
| _ -> ()
) daemon_functions;
let groups = Hashtbl.fold (fun k _ ks -> k :: ks) h [] in
let groups =
List.map (
fun group -> group, List.sort compare (Hashtbl.find h group)
) groups in
List.sort (fun x y -> compare (fst x) (fst y)) groups