Skip to content

Commit

Permalink
Revert "add OpamConsole.Tree.to_json"
Browse files Browse the repository at this point in the history
This reverts commit c56c506.
  • Loading branch information
cannorin authored and kit-ty-kate committed Jul 29, 2022
1 parent 1ec0ba0 commit f946b3f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 15 deletions.
11 changes: 0 additions & 11 deletions src/core/opamConsole.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1102,17 +1102,6 @@ module Tree = struct
Buffer.add_char buff '\n';
go_children "" children;
msg "%s" (Buffer.contents buff)

let rec to_json ?(flatten=false) ~encoder { value; children } : OpamJson.t =
let fields =
match children with
| [] -> []
| _ -> ["children", `A (List.map (to_json ~flatten ~encoder) children)]
in
match flatten, encoder value with
| false, value -> `O (("value", value) :: fields)
| true, `O fields' -> `O (fields' @ fields)
| _, _ -> invalid_arg "encoder returned a non-object value"
end

(* This allows OpamStd.Config.env to display warning messages *)
Expand Down
4 changes: 0 additions & 4 deletions src/core/opamConsole.mli
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,4 @@ module Tree : sig
(** Prints the given tree as a Unicode/ASCII art.
@param printer may return a multi-line string, but should not return an empty string. *)
val print: ?symbols:symbols -> printer:('a -> string) -> 'a t -> unit

(** Encodes the given tree as JSON.
@param encoder must return [`O fields] when [~flatten:true]. *)
val to_json: ?flatten:bool -> encoder:('a -> OpamJson.t) -> 'a t -> OpamJson.t
end

0 comments on commit f946b3f

Please sign in to comment.