unison

Fork of Unison, a bi-directional file synchronization tool
git clone git://git.laack.co/unison.git
Log | Files | Refs | README | LICENSE

uicommon.mli (5090B)


      1 (* Unison file synchronizer: src/uicommon.mli *)
      2 (* Copyright 1999-2020, Benjamin C. Pierce (see COPYING for details) *)
      3 
      4 (* Kinds of UI *)
      5 type interface =
      6    Text
      7  | Graphic
      8 
      9 val minterface : interface Umarshal.t
     10 
     11 (* The interface of a concrete UI implementation *)
     12 module type UI =
     13 sig
     14   val start : interface -> unit
     15   val defaultUi : interface
     16 end
     17 
     18 (* User preference: when true, ask fewer questions *)
     19 val auto : bool Prefs.t
     20 
     21 (* User preference: How tall to make the main window in the GTK ui *)
     22 val mainWindowHeight : int Prefs.t
     23 
     24 (* User preference: Expert mode *)
     25 val expert : bool Prefs.t
     26 
     27 (* User preference: Whether to display 'contacting server' message *)
     28 val contactquietly : bool Prefs.t
     29 
     30 (* User preference: The 'contacting server' message itself *)
     31 val contactingServerMsg : unit -> string
     32 
     33 (* User preference: Descriptive label for this profile *)
     34 val profileLabel : string Prefs.t
     35 
     36 (* User preference: Synchronize repeatedly *)
     37 val repeat : [ `NoRepeat | `Interval of int | `Watch
     38   | `WatchAndInterval of int | `Invalid of string * exn ] Prefs.t
     39 
     40 (* User preference: Try failing paths N times *)
     41 val retry : int Prefs.t
     42 
     43 (* User preference: confirmation before committing merge results *)
     44 val confirmmerge : bool Prefs.t
     45 
     46 val runTestsPrefName : string
     47 
     48 val runtests : bool Prefs.t
     49 
     50 val testServer : bool Prefs.t
     51 
     52 (* Format the information about current contents of a path in one replica (the second argument
     53    is used as a separator) *)
     54 val details2string : Common.reconItem -> string -> string
     55 
     56 (* Format a path, eliding initial components that are the same as the
     57    previous path *)
     58 val displayPath : Path.t -> Path.t -> string
     59 
     60 (* Format the names of the roots for display at the head of the
     61    corresponding columns in the UI *)
     62 val roots2string : unit -> string
     63 val roots2niceStrings : int -> Common.root * Common.root -> string * string
     64 
     65 (* Format a reconItem (and its status string) for display, eliding
     66    initial components that are the same as the previous path *)
     67 val reconItem2string : Path.t -> Common.reconItem -> string -> string
     68 
     69 type action = AError | ASkip of bool | ALtoR of bool | ARtoL of bool | AMerge
     70 
     71 (* Same as previous function, but returns a tuple of strings *)
     72 val reconItem2stringList :
     73   Path.t -> Common.reconItem -> string * action * string * string
     74 
     75 (* Format an exception for display *)
     76 val exn2string : exn -> string
     77 
     78 (* Calculate and display differences for a file *)
     79 val showDiffs :
     80      Common.reconItem           (* what path *)
     81   -> (string->string->unit)     (* how to display the (title and) result *)
     82   -> (string->unit)             (* how to display errors *)
     83   -> Uutil.File.t               (* id for transfer progress reports *)
     84   -> unit
     85 
     86 val dangerousPathMsg : Path.t list -> string
     87 
     88 (* Utilities for adding ignore patterns *)
     89 val ignorePath : Path.t -> string
     90 val ignoreName : Path.t -> string
     91 val ignoreExt  : Path.t -> string
     92 val addIgnorePattern : string -> unit
     93 
     94 val usageMsg : string
     95 
     96 val shortUsageMsg : string
     97 
     98 val uiInitClRootsAndProfile :
     99     ?prepDebug:(unit -> unit) ->
    100     unit ->
    101     (string option, string) result
    102 
    103 val initPrefs :
    104   profileName:string ->
    105   promptForRoots:(unit -> (string * string) option) ->
    106   ?prepDebug:(unit -> unit) ->
    107   unit ->
    108   unit
    109 
    110 val clearClRoots : unit -> unit
    111 
    112 (* Make sure remote connections (if any) corresponding to active roots
    113    are established and (re-)establish them if necessary.
    114    [initPrefs] must be called before [connectRoots]. *)
    115 val connectRoots :
    116   ?termInteract:(string -> Terminal.termInteract) ->
    117   displayWaitMessage:(unit -> unit) ->
    118   unit ->
    119   unit
    120 
    121 val validateAndFixupPrefs : unit -> unit Lwt.t
    122 
    123 (* Exit codes *)
    124 val perfectExit: int   (* when everything's okay *)
    125 val skippyExit: int    (* when some items were skipped, but no failure occurred *)
    126 val failedExit: int    (* when there's some non-fatal failure *)
    127 val fatalExit: int     (* when fatal failure occurred *)
    128 val exitCode: bool * bool -> int
    129 (* (anySkipped?, anyFailure?) -> exit code *)
    130 
    131 (* Initialization *)
    132 val testFunction : (unit->unit) ref
    133 
    134 (* Profile scanning and selection *)
    135 type profileInfo = {roots:string list; label:string option; key:string option}
    136 
    137 val profileKeymap : (string * profileInfo) option array
    138 
    139 val profilesAndRoots : (string * profileInfo) list ref
    140 
    141 val scanProfiles : unit -> unit
    142 
    143 (* Update propagation *)
    144 val transportStart : unit -> unit
    145 val transportFinish : unit -> unit
    146 
    147 val transportItems : 'a array -> ('a -> bool) -> (int -> 'a -> unit Lwt.t) -> unit
    148 
    149 (* Statistics of update propagation *)
    150 module Stats : sig
    151   type t
    152   val init :
    153        Uutil.Filesize.t (* Total size to complete 100% *)
    154     -> t
    155   val update :
    156        t
    157     -> float            (* Current absolute time *)
    158     -> Uutil.Filesize.t (* Current completed size (not delta) *)
    159     -> unit
    160   val curRate : t -> float (* Current progress rate, very volatile *)
    161   val avgRate1 : t -> float (* Moving average of the rate above, more stable *)
    162   val avgRate2 : t -> float (* Double moving average, very stable *)
    163   val eta : t -> ?rate:float -> string -> string (* Defaults to rate2 *)
    164 end