Skip to content

Commit

Permalink
Merge pull request #39 from hammerlab/conv-changes
Browse files Browse the repository at this point in the history
Cmdliner.Arg.conv
  • Loading branch information
ihodes authored Jan 30, 2020
2 parents ad92d32 + 9ddf8ba commit c65cb9b
Show file tree
Hide file tree
Showing 9 changed files with 217 additions and 254 deletions.
2 changes: 2 additions & 0 deletions dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(lang dune 1.0)
(name ppx_deriving_cmdliner)
4 changes: 0 additions & 4 deletions jbuild-workspace.dev

This file was deleted.

6 changes: 3 additions & 3 deletions ppx_deriving_cmdliner.opam
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ license: "MIT"
version: "0.4.2-dev"
tags: ["syntax" "cli"]
build: [
["jbuilder" "subst" "-n" name] {pinned}
["jbuilder" "build" "-p" name "-j" jobs]
["dune" "subst"] {pinned}
["dune" "build" "-p" name "-j" jobs]
]
run-test: [
["jbuilder" "runtest" "-p" name "-j" jobs]
["dune" "runtest" "-p" name "-j" jobs]
]
depends: [
"ocaml" {>= "4.03"}
Expand Down
26 changes: 26 additions & 0 deletions src/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
(rule
(deps
(:< ppx_deriving_cmdliner.cppo.ml))
(targets ppx_deriving_cmdliner.ml)
(action
(run %{bin:cppo} -V OCAML:%{ocaml_version} %{<} -o %{targets})))

(library
(name ppx_deriving_cmdliner_runtime)
(public_name ppx_deriving_cmdliner.runtime)
(synopsis "Runtime components of [@@deriving cmdliner]")
(modules ppx_deriving_cmdliner_runtime)
(libraries ppx_deriving.runtime result))

(library
(name ppx_deriving_cmdliner)
(public_name ppx_deriving_cmdliner)
(synopsis "[@@deriving cmdliner]")
(libraries ppx_deriving.api)
(preprocess
(action
(run ppxfind -legacy ppx_tools.metaquot --as-pp %{input-file})))
(ppx_runtime_libraries ppx_deriving_cmdliner_runtime cmdliner)
(flags :standard -w -9-27-39)
(modules ppx_deriving_cmdliner)
(kind ppx_deriver))
22 changes: 0 additions & 22 deletions src/jbuild

This file was deleted.

6 changes: 3 additions & 3 deletions src/ppx_deriving_cmdliner.cppo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ let rec converter_for ?list_sep ?enum typ =
(* ^ Print inside a pretty box to ignore raw new lines in comments. *)
| _, { ptyp_desc = Ptyp_constr ({ txt = lid }, args) } ->
let fn_name = Ppx_deriving.mangle_lid (`Suffix "cmdliner_converter") lid in
[%expr Cmdliner.Arg.conv [%e Exp.ident (mknoloc fn_name)]]
[%expr [%e Exp.ident (mknoloc fn_name)]]
| _, _ ->
failwith
(Printf.sprintf
Expand Down Expand Up @@ -188,7 +188,7 @@ let rec ser_expr_of_typ typ attrs name =
let enum = attr_expr attrs "enum" in
let conv' = match attr_expr attrs "conv" with
| None -> converter_for ?list_sep ?enum typ
| Some conv -> [%expr Cmdliner.Arg.conv [%e conv]]
| Some conv -> conv
in
let pos = attr_int_opt "pos" attrs in
let info' = info_for ?pos ~attrs ~name ?list_sep ~typ ~env:env' in
Expand Down Expand Up @@ -231,7 +231,7 @@ let rec ser_expr_of_typ typ attrs name =
when key_attr_exists attrs "opt_all" ->
let conv' = match attr_expr attrs "conv" with
| None -> converter_for ?list_sep ?enum:(attr_expr attrs "enum") typ
| Some conv -> [%expr Cmdliner.Arg.conv [%e conv]]
| Some conv -> conv
in
begin match default' with
| None -> [%expr
Expand Down
13 changes: 13 additions & 0 deletions test/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(executable
(name test_ppx_deriving_cmdliner)
(libraries alcotest result)
(flags :standard -w -27-39)
(preprocess
(pps ppx_deriving.show ppx_deriving_cmdliner)))

(alias
(name runtest)
(deps
(:< test_ppx_deriving_cmdliner.exe))
(action
(run %{<})))
12 changes: 0 additions & 12 deletions test/jbuild

This file was deleted.

Loading

0 comments on commit c65cb9b

Please sign in to comment.