-
Notifications
You must be signed in to change notification settings - Fork 395
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(describe): remove describe_common lib
Signed-off-by: Ali Caglayan <alizter@gmail.com>
- Loading branch information
Showing
7 changed files
with
230 additions
and
319 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
open Stdune | ||
open Import | ||
|
||
type t = | ||
| Sexp | ||
| Csexp | ||
|
||
let all = [ ("sexp", Sexp); ("csexp", Csexp) ] | ||
|
||
let arg = | ||
let doc = Printf.sprintf "$(docv) must be %s" (Arg.doc_alts_enum all) in | ||
Arg.(value & opt (enum all) Sexp & info [ "format" ] ~docv:"FORMAT" ~doc) | ||
|
||
let print_as_sexp dyn = | ||
let rec dune_lang_of_sexp : Sexp.t -> Dune_lang.t = function | ||
| Atom s -> Dune_lang.atom_or_quoted_string s | ||
| List l -> List (List.map l ~f:dune_lang_of_sexp) | ||
in | ||
let cst = | ||
dyn |> Sexp.of_dyn |> dune_lang_of_sexp | ||
|> Dune_lang.Ast.add_loc ~loc:Loc.none | ||
|> Dune_lang.Cst.concrete | ||
in | ||
let version = Dune_lang.Syntax.greatest_supported_version Stanza.syntax in | ||
Pp.to_fmt Stdlib.Format.std_formatter | ||
(Dune_lang.Format.pp_top_sexps ~version [ cst ]) | ||
|
||
let print_dyn t dyn = | ||
match t with | ||
| Csexp -> Csexp.to_channel stdout (Sexp.of_dyn dyn) | ||
| Sexp -> print_as_sexp dyn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
open Import | ||
|
||
(** Formatting utilities for dune describe commands *) | ||
|
||
type t = | ||
| Sexp | ||
| Csexp | ||
|
||
val arg : t Term.t | ||
|
||
val print_dyn : t -> Dyn.t -> unit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.