<commit_before>(*
 * XmlRpc Light, a small XmlRpc library based on Xml Light and Ocamlnet
 * Copyright (C) 2007-2008 <NAME> (<EMAIL>)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *)

open Printf

module StringMap = Map.Make(String)

let url = ref ""

let use_int32 = ref false
let use_multicall = ref false
let verbose = ref false

let variant_name = function
  | `String "array" -> Some "`Array"
  | `String "base64" -> Some "`Binary"
  | `String "boolean" -> Some "`Boolean"
  | `String "dateTime.iso8601" -> Some "`DateTime"
  | `String "double" -> Some "`Double"
  | `String "int" -> Some (if !use_int32 then "`Int32" else "`Int")
  | `String "string" -> Some "`String"
  | `String "struct" -> Some "`Struct"
  | `String "undefined" -> None
  | _ as it -> failwith (XmlRpc.dump it)

let dot_to_underscore s =
  let s = String.copy s in
  let len = String.length s in
  for i = 0 to len - 1 do
    match s.[i] with
      | '.' -> s.[i] <- '_'
      | _ -> ()
  done;
  s

let () =
  let specs = 
    ["-i", Arg.Set use_int32, "Use int32 for all integers";
     "-m", Arg.Set use_multicall, "Generate lazy interface using multicall";
     "-v", Arg.Set verbose, "Display verbose debugging output"] in
  let usage = (sprintf "Usage: %s [-i] url" Sys.argv.(0)) in
  Arg.parse specs (fun url' -> url := url') usage;
  if !url = "" then (Arg.usage specs usage; exit 2)

let rpc = new XmlRpc.client ~debug:!verbose !url

let methods = rpc#call "system.listMethods" []

let mc = new XmlRpc.multicall rpc
let signatures =
  match methods with
    | `Array methods ->
        List.map
          (function
             | `String meth ->
                 (meth, mc#call "system.methodSignature" [`String meth])
             | _ -> failwith "got non-string for method name")
          methods
    | _ -> failwith "got non-array from system.listMethods"

let module_map =
  List.fold_left
    (fun acc (name, signature) -><commit_msg>Add missing options to usage message<commit_after>(*
 * XmlRpc Light, a small XmlRpc library based on Xml Light and Ocamlnet
 * Copyright (C) 2007-2008 <NAME> (<EMAIL>)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *)

open Printf

module StringMap = Map.Make(String)

let url = ref ""

let use_int32 = ref false
let use_multicall = ref false
let verbose = ref false

let variant_name = function
  | `String "array" -> Some "`Array"
  | `String "base64" -> Some "`Binary"
  | `String "boolean" -> Some "`Boolean"
  | `String "dateTime.iso8601" -> Some "`DateTime"
  | `String "double" -> Some "`Double"
  | `String "int" -> Some (if !use_int32 then "`Int32" else "`Int")
  | `String "string" -> Some "`String"
  | `String "struct" -> Some "`Struct"
  | `String "undefined" -> None
  | _ as it -> failwith (XmlRpc.dump it)

let dot_to_underscore s =
  let s = String.copy s in
  let len = String.length s in
  for i = 0 to len - 1 do
    match s.[i] with
      | '.' -> s.[i] <- '_'
      | _ -> ()
  done;
  s

let () =
  let specs = 
    ["-i", Arg.Set use_int32, "Use int32 for all integers";
     "-m", Arg.Set use_multicall, "Generate lazy interface using multicall";
     "-v", Arg.Set verbose, "Display verbose debugging output"] in
  let usage = (sprintf "Usage: %s [-i] [-m] [-v] url" Sys.argv.(0)) in
  Arg.parse specs (fun url' -> url := url') usage;
  if !url = "" then (Arg.usage specs usage; exit 2)

let rpc = new XmlRpc.client ~debug:!verbose !url

let methods = rpc#call "system.listMethods" []

let mc = new XmlRpc.multicall rpc
let signatures =
  match methods with
    | `Array methods ->
        List.map
          (function
             | `String meth ->
                 (meth, mc#call "system.methodSignature" [`String meth])
             | _ -> failwith "got non-string for method name")
          methods
    | _ -> failwith "got non-array from system.listMethods"

let module_map =
  List.fold_left
    (fun acc (name, signature) ->
{'fraction_non_alphanumeric': 0.11762473913868336, 'fraction_numerical': 0.01669512426484538, 'mean_word_length': 2.993939393939394, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3806682', 'n_tokens_mistral': 1728, 'n_tokens_neox': 1611, 'n_words': 665}