Skip to content

Commit

Permalink
dune init lib --public: allow dashes etc
Browse files Browse the repository at this point in the history
Signed-off-by: Reynir Björnsson <reynir@reynir.dk>
  • Loading branch information
reynir committed Mar 1, 2023
1 parent d3d628f commit 0ffb7de
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions bin/init.ml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,23 @@ let component_name_conv = Arg.conv (component_name_parser, atom_printer)

let public_name_conv =
let open Component.Options in
let parser = function
| "" -> Ok Use_name
| s -> component_name_parser s |> Result.map ~f:(fun a -> Public_name a)
let parser s =
let err_msg () =
User_error.make
[ Pp.textf "invalid public library name `%s'" s
; Lib_name.Local.valid_format_doc
]
|> User_message.to_string
|> fun m -> `Msg m
in
let open Result.O in
let* atom = atom_parser s in
let* _ =
match Lib_name.of_string_opt s with
| None -> Error (err_msg ())
| Some s -> Ok s
in
Ok (Public_name atom)
in
let printer ppf public_name =
Format.pp_print_string ppf (public_name_to_string public_name)
Expand Down

0 comments on commit 0ffb7de

Please sign in to comment.