<commit_before>open Lwt
open React

let start_client cfgdir debug () =
  ignore (LTerm_inputrc.load ());
  Tls_lwt.rng_init () >>= fun () ->

  Lazy.force LTerm.stdout >>= fun term ->


  Xmpp_callbacks.load_config cfgdir >>= ( function
      | None ->
        Cli_config.configure term () >>= fun config ->
        Xmpp_callbacks.dump_config cfgdir config >|= fun () ->
        config
      | Some cfg -> return cfg ) >>= fun config ->

  Xmpp_callbacks.load_users cfgdir >>= fun (users) ->

  let history = LTerm_history.create [] in
  let user = User.find_or_add config.Config.jid users in
  let session = User.ensure_session config.Config.jid config.Config.otr_config user in
  let state = Cli_state.empty_ui_state user session users in
  let n, s_n = S.create (Unix.localtime (Unix.time ()), "nobody", "nothing") in
  ( if debug then
      let f = Filename.concat (Unix.getenv "PWD") "out.txt" in
      Lwt.catch (fun () ->
          Lwt_unix.openfile f Unix.([O_WRONLY ; O_CREAT ; O_APPEND ]) 0o600 >|= fun fd ->
          Some fd)
        (fun _ -> return None)
    else
      return None ) >>= fun out ->
  Cli_client.loop ?out config term history state None n s_n >>= fun state ->
  ( match out with
    | None -> return_unit
    | Some fd -> Lwt_unix.close fd ) >>= fun () ->
  Xmpp_callbacks.dump_users cfgdir state.Cli_state.users

let config_dir = ref ""
let debug = ref false<commit_msg>style<commit_after>open Lwt
open React

let start_client cfgdir debug () =
  ignore (LTerm_inputrc.load ());
  Tls_lwt.rng_init () >>= fun () ->

  Lazy.force LTerm.stdout >>= fun term ->

  Xmpp_callbacks.load_config cfgdir >>= ( function
      | None ->
        Cli_config.configure term () >>= fun config ->
        Xmpp_callbacks.dump_config cfgdir config >|= fun () ->
        config
      | Some cfg -> return cfg ) >>= fun config ->

  Xmpp_callbacks.load_users cfgdir >>= fun (users) ->

  let history = LTerm_history.create [] in
  let user = User.find_or_add config.Config.jid users in
  let session = User.ensure_session config.Config.jid config.Config.otr_config user in
  let state = Cli_state.empty_ui_state user session users in
  let n, s_n = S.create (Unix.localtime (Unix.time ()), "nobody", "nothing") in
  ( if debug then
      let f = Filename.concat (Unix.getenv "PWD") "out.txt" in
      Lwt.catch (fun () ->
          Lwt_unix.openfile f Unix.([O_WRONLY ; O_CREAT ; O_APPEND ]) 0o600 >|= fun fd ->
          Some fd)
        (fun _ -> return None)
    else
      return None ) >>= fun out ->
  Cli_client.loop ?out config term history state None n s_n >>= fun state ->
  ( match out with
    | None -> return_unit
    | Some fd -> Lwt_unix.close fd ) >>= fun () ->
  Xmpp_callbacks.dump_users cfgdir state.Cli_state.users


let config_dir = ref ""
let debug = ref false
{'fraction_non_alphanumeric': 0.12455261274158912, 'fraction_numerical': 0.002863278453829635, 'mean_word_length': 2.7719298245614037, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 75, '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': '1596170', 'n_tokens_mistral': 983, 'n_tokens_neox': 950, 'n_words': 265}