Source file output.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
open! Core
open! Import
include Output_intf

type t =
  | Ansi
  | Ascii
  | Html
[@@deriving compare ~localize, sexp]

let implies_unrefined t =
  match t with
  | Ansi | Html -> false
  | Ascii -> true
;;

let flag =
  let open Command.Param in
  choose_one
    [ map
        ~f:(function
          | true -> Some (Some Html)
          | _ -> None)
        (flag
           "html"
           no_arg
           ~doc:" Output in HTML format instead of default (ASCII with ANSI escape codes)")
    ; map
        ~f:(function
          | true -> Some (Some Ascii)
          | _ -> None)
        (flag
           "ascii"
           no_arg
           ~doc:" Output in ASCII with no ANSI escape codes (implies unrefined diff)")
    ; map
        ~f:(function
          | true -> Some (Some Ansi)
          | _ -> None)
        (flag "ansi" no_arg ~doc:" Output in ASCII with ANSI escape codes")
    ]
    ~if_nothing_chosen:(Default_to None)
;;