Skip to content

Commit

Permalink
refactor OptionState about input_file
Browse files Browse the repository at this point in the history
  • Loading branch information
gfngfn committed Oct 29, 2023
1 parent 5176297 commit b586422
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 34 deletions.
21 changes: 4 additions & 17 deletions src/backend/optionState.ml
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@

open MyUtil

type build_state = {
input_file : abs_path;
}

type test_state = {
input_file_to_test : abs_path;
}

type command_state =
| BuildState of build_state
| TestState of test_state
| SolveState

type state = {
command_state : command_state;
input_file : abs_path option;
show_full_path : bool;
}

Expand All @@ -34,10 +22,9 @@ let get () =


let get_input_file () =
match (get ()).command_state with
| BuildState({ input_file; _ }) -> input_file
| TestState({ input_file_to_test; _}) -> input_file_to_test
| SolveState -> assert false
match (get ()).input_file with
| Some(input_file) -> input_file
| None -> assert false


let does_show_full_path () =
Expand Down
15 changes: 1 addition & 14 deletions src/backend/optionState.mli
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@

open MyUtil

type build_state = {
input_file : abs_path;
}

type test_state = {
input_file_to_test : abs_path;
}

type command_state =
| BuildState of build_state
| TestState of test_state
| SolveState

type state = {
command_state : command_state;
input_file : abs_path option;
show_full_path : bool;
}

Expand Down
6 changes: 3 additions & 3 deletions src/frontend/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1657,7 +1657,7 @@ let build
}
in
OptionState.set OptionState.{
command_state = BuildState{ input_file };
input_file = Some(input_file);
show_full_path;
};

Expand Down Expand Up @@ -1791,7 +1791,7 @@ let test
}
in
OptionState.set OptionState.{
command_state = TestState{ input_file_to_test };
input_file = Some(input_file_to_test);
show_full_path;
};

Expand Down Expand Up @@ -2009,7 +2009,7 @@ let solve
let extra_config_paths = config_paths_str_opt |> Option.map (String.split_on_char ':') in

OptionState.set OptionState.{
command_state = SolveState;
input_file = None;
show_full_path;
};

Expand Down

0 comments on commit b586422

Please sign in to comment.