@@ -176,6 +176,7 @@ type t =
176176 | Substitute of String_with_vars .t * String_with_vars .t
177177 | Withenv of String_with_vars .t Env_update .t list * t
178178 | When of Slang .blang * t
179+ | Format_dune_file of String_with_vars .t * String_with_vars .t
179180
180181let is_dev_null t = String_with_vars. is_pform t (Var Dev_null )
181182
@@ -350,6 +351,11 @@ let cstrs_dune_file t =
350351 , Syntax. since Stanza. syntax (2 , 7 )
351352 >>> let + script = sw in
352353 Cram script )
354+ ; ( " format-dune-file"
355+ , Syntax. since Stanza. syntax (3 , 18 )
356+ >>> let + src = sw
357+ and + dst = sw in
358+ Format_dune_file (src, dst) )
353359 ]
354360;;
355361
@@ -458,6 +464,7 @@ let rec encode =
458464 List [ atom " withenv" ; List (List. map ~f: Env_update. encode ops); encode t ]
459465 | When (condition , action ) ->
460466 List [ atom " when" ; Slang. encode_blang condition; encode action ]
467+ | Format_dune_file (src , dst ) -> List [ atom " format-dune-file" ; sw src; sw dst ]
461468;;
462469
463470(* In [Action_exec] we rely on one-to-one mapping between the cwd-relative paths
@@ -495,7 +502,8 @@ let ensure_at_most_one_dynamic_run ~loc action =
495502 | Diff _
496503 | Substitute _
497504 | Patch _
498- | Cram _ -> false
505+ | Cram _
506+ | Format_dune_file _ -> false
499507 | Pipe (_ , ts ) | Progn ts | Concurrent ts ->
500508 List. fold_left ts ~init: false ~f: (fun acc t ->
501509 let have_dyn = loop t in
@@ -597,6 +605,7 @@ let rec map_string_with_vars t ~f =
597605 When
598606 ( blang_map_string_with_vars condition ~f: (slang_map_string_with_vars ~f )
599607 , map_string_with_vars t ~f )
608+ | Format_dune_file (src , dst ) -> Format_dune_file (f src, f dst)
600609;;
601610
602611let remove_locs = map_string_with_vars ~f: String_with_vars. remove_locs
0 commit comments