Skip to content

Commit

Permalink
Replace with self written color codes
Browse files Browse the repository at this point in the history
  • Loading branch information
dmtrKovalenko committed Aug 24, 2024
1 parent 1a8ca30 commit ce1df85
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
26 changes: 16 additions & 10 deletions bin/Print.ml
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
open Odiff.Diff

let esc = "\027["
let red = esc ^ "31m"
let green = esc ^ "32m"
let bold = esc ^ "1m"
let dim = esc ^ "2m"
let reset = esc ^ "0m"

let printDiffResult makeParsableOutput result =
let reset_ppf = Spectrum.prepare_ppf Format.str_formatter in
(match (result, makeParsableOutput) with
| Layout, true -> ()
| Layout, false ->
Spectrum.Simple.printf "@{<red>%s!@} Images have different layout.\n"
"Failure!"
Format.printf "%s%sFailure!%s Images have different layout.\n" red bold
reset
| Pixel (_output, diffCount, diffPercentage, stack), true
when not (Stack.is_empty stack) ->
Int.to_string diffCount ^ ";"
Expand All @@ -20,13 +26,13 @@ let printDiffResult makeParsableOutput result =
|> print_endline
| Pixel (_output, diffCount, _percentage, _lines), false when diffCount == 0
->
Spectrum.Simple.printf
"@{<green><bold>Success!@} Images are equal.\n\
@{<dim>No diff output created.@}"
Format.printf
"%s%sSuccess!%s Images are equal.\n%sNo diff output created.%s\n" green
bold reset dim reset
| Pixel (_output, diffCount, diffPercentage, _lines), false ->
Spectrum.Simple.printf
"@{<red,bold>Failure!@} Images are different.\n\
Different pixels: @{<red,bold>%i (%f%%)@}" diffCount diffPercentage);
Format.printf
"%s%sFailure!%s Images are different.\n\
Different pixels: %s%s%i (%f%%)%s\n"
red bold reset red bold diffCount diffPercentage reset);

reset_ppf ();
result
5 changes: 3 additions & 2 deletions bin/dune
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
(package odiff)
(flags
(:standard -w -27))
(libraries odiff-core odiff-io cmdliner spectrum))
(libraries odiff-core odiff-io cmdliner))

(env
(dev
(flags (:standard -w +42)))
(flags (:standard -w +42))
(ocamlopt_flags (:standard -S)))
(release
(ocamlopt_flags (:standard -O3 -rounds 5 -unbox-closures -inline 200 -inline-max-depth 7 -unbox-closures-factor 50))))

1 change: 0 additions & 1 deletion dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
odiff-core
odiff-io
(cmdliner (= 1.3.0))
(spectrum (= 0.6.0))
)
)

Expand Down
1 change: 0 additions & 1 deletion odiff.opam
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ depends: [
"odiff-core"
"odiff-io"
"cmdliner" {= "1.3.0"}
"spectrum" {= "0.6.0"}
"odoc" {with-doc}
]
build: [
Expand Down

0 comments on commit ce1df85

Please sign in to comment.