Add Stanza.file_kind
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
This commit is contained in:
parent
f46a6aae53
commit
daa4be3dd8
|
@ -89,14 +89,22 @@ struct
|
||||||
; "diff",
|
; "diff",
|
||||||
(path >>= fun file1 ->
|
(path >>= fun file1 ->
|
||||||
path >>= fun file2 ->
|
path >>= fun file2 ->
|
||||||
Syntax.get_exn Stanza.syntax >>| fun ver ->
|
Stanza.file_kind () >>| fun kind ->
|
||||||
let mode = if ver < (1, 0) then Diff_mode.Text_jbuild else Text in
|
let mode =
|
||||||
|
match kind with
|
||||||
|
| Jbuild -> Diff_mode.Text_jbuild
|
||||||
|
| Dune -> Text
|
||||||
|
in
|
||||||
Diff { optional = false; file1; file2; mode })
|
Diff { optional = false; file1; file2; mode })
|
||||||
; "diff?",
|
; "diff?",
|
||||||
(path >>= fun file1 ->
|
(path >>= fun file1 ->
|
||||||
path >>= fun file2 ->
|
path >>= fun file2 ->
|
||||||
Syntax.get_exn Stanza.syntax >>| fun ver ->
|
Stanza.file_kind () >>| fun kind ->
|
||||||
let mode = if ver < (1, 0) then Diff_mode.Text_jbuild else Text in
|
let mode =
|
||||||
|
match kind with
|
||||||
|
| Jbuild -> Diff_mode.Text_jbuild
|
||||||
|
| Dune -> Text
|
||||||
|
in
|
||||||
Diff { optional = true; file1; file2; mode })
|
Diff { optional = true; file1; file2; mode })
|
||||||
; "cmp",
|
; "cmp",
|
||||||
(Syntax.since Stanza.syntax (1, 0) >>= fun () ->
|
(Syntax.since Stanza.syntax (1, 0) >>= fun () ->
|
||||||
|
|
|
@ -11,3 +11,12 @@ let syntax =
|
||||||
[ (0, 0) (* Jbuild syntax *)
|
[ (0, 0) (* Jbuild syntax *)
|
||||||
; (1, 0)
|
; (1, 0)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
module File_kind = struct
|
||||||
|
type t = Jbuild | Dune
|
||||||
|
end
|
||||||
|
|
||||||
|
let file_kind () =
|
||||||
|
let open Sexp.Of_sexp in
|
||||||
|
Syntax.get_exn syntax >>| fun ver ->
|
||||||
|
if ver < (1, 0) then File_kind.Jbuild else Dune
|
||||||
|
|
|
@ -16,3 +16,10 @@ end
|
||||||
the Jbuild language while versions from [(1, 0)] correspond to the
|
the Jbuild language while versions from [(1, 0)] correspond to the
|
||||||
Dune one. *)
|
Dune one. *)
|
||||||
val syntax : Syntax.t
|
val syntax : Syntax.t
|
||||||
|
|
||||||
|
module File_kind : sig
|
||||||
|
type t = Jbuild | Dune
|
||||||
|
end
|
||||||
|
|
||||||
|
(** Whether we are parsing a [jbuild] or [dune] file. *)
|
||||||
|
val file_kind : unit -> (File_kind.t, _) Sexp.Of_sexp.parser
|
||||||
|
|
Loading…
Reference in New Issue