Skip to content

Commit

Permalink
Remove pointless polymorphic variant and check_path
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
  • Loading branch information
rgrinberg committed Aug 7, 2018
1 parent 6dc6ac3 commit 9a504bc
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -659,9 +659,12 @@ let check_path contexts =
name
(hint name (String.Set.to_list contexts))

type resolve_input =
| Path of Path.t
| String of string

let resolve_path path ~(setup : Main.setup) =
let check_path = check_path setup.contexts in
check_path path;
check_path setup.contexts path;
let can't_build path =
Error (path, target_hint setup path);
in
Expand All @@ -685,7 +688,6 @@ let resolve_path path ~(setup : Main.setup) =
| l -> Ok l

let resolve_target common ~(setup : Main.setup) s =
let check_path = check_path setup.contexts in
if String.is_prefix s ~prefix:"@" then begin
let pos, is_rec =
if String.length s >= 2 && s.[1] = '@' then
Expand All @@ -695,7 +697,7 @@ let resolve_target common ~(setup : Main.setup) s =
in
let s = String.sub s ~pos ~len:(String.length s - pos) in
let path = Path.relative Path.root (prefix_target common s) in
check_path path;
check_path setup.contexts path;
if Path.is_root path then
die "@@ on the command line must be followed by a valid alias name"
else if not (Path.is_managed path) then
Expand Down Expand Up @@ -725,8 +727,8 @@ let resolve_targets_mixed ~log common (setup : Main.setup) user_targets =
| _ ->
let targets =
List.map user_targets ~f:(function
| `String s -> resolve_target common ~setup s
| `Path p -> resolve_path p ~setup) in
| String s -> resolve_target common ~setup s
| Path p -> resolve_path p ~setup) in
if common.config.display = Verbose then begin
Log.info log "Actual targets:";
List.concat_map targets ~f:(function
Expand All @@ -737,7 +739,7 @@ let resolve_targets_mixed ~log common (setup : Main.setup) user_targets =
targets

let resolve_targets ~log common (setup : Main.setup) user_targets =
List.map ~f:(fun s -> `String s) user_targets
List.map ~f:(fun s -> String s) user_targets
|> resolve_targets_mixed ~log common setup

let resolve_targets_exn ~log common setup user_targets =
Expand Down Expand Up @@ -1242,7 +1244,7 @@ let exec =
[p]
| `This_abs _ ->
[])
|> List.map ~f:(fun p -> `Path p)
|> List.map ~f:(fun p -> Path p)
|> resolve_targets_mixed ~log common setup
|> List.concat_map ~f:(function
| Ok targets -> targets
Expand Down

0 comments on commit 9a504bc

Please sign in to comment.