Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove unused arguments from Key.context #1450

Merged
merged 1 commit into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/functoria/key.ml
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,8 @@ let create name arg =

(* {2 Cmdliner interface} *)

let context ?(stage = `Both) l =
let stage = filter_stage stage l in
let context l =
let stage = filter_stage `Configure l in
let names = Names.of_list (Set.elements stage) in
let gather (Any k) rest =
let f v p = match v with None -> p | Some v -> Context.add k.key v p in
Expand Down
2 changes: 1 addition & 1 deletion lib/functoria/key.mli
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ type context := Context.t
val add_to_context : 'a key -> 'a -> context -> context
(** Add a binding to a context. *)

val context : ?stage:Arg.stage -> Set.t -> context Cmdliner.Term.t
val context : Set.t -> context Cmdliner.Term.t
(** [context ks] is a [Cmdliner]
{{:http://erratique.ch/software/cmdliner/doc/Cmdliner/Term/index.html#type-t}
term} that evaluates into a parsing context for command-line arguments. *)
Expand Down
4 changes: 2 additions & 2 deletions lib/functoria/lib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ module Make (P : S) = struct
| Some _, _ -> output
| _, cache -> cache
in
let context = Key.context ~stage:`Configure keys in
let context = Key.context keys in
let context = Context_cache.merge cache context in
let f context =
let config = Key.eval context info context in
Expand Down Expand Up @@ -458,7 +458,7 @@ module Make (P : S) = struct
(* Consider only the non-required keys. *)
let non_required_term =
let if_keys = Config.keys config in
Key.context ~stage:`Configure if_keys
Key.context if_keys
in
let context =
match Cmdliner.Cmd.eval_peek_opts ~argv non_required_term with
Expand Down
3 changes: 1 addition & 2 deletions lib/functoria/tool.ml
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ module Make (P : S) = struct
(* Extract all the keys directly. Useful to pre-resolve the keys
provided by the specialized DSL. *)
let base_keys = Engine.all_keys @@ Impl.abstract @@ P.create [] in
Cmdliner.Term.(
const (fun _ -> Action.ok ()) $ Key.context base_keys ~stage:`Configure)
Cmdliner.Term.(const (fun _ -> Action.ok ()) $ Key.context base_keys)
in
let result =
Cli.eval ?help_ppf ?err_ppf ~name:P.name ~version:P.version
Expand Down