Skip to content

Commit

Permalink
refactor: remove unused arguments from Key.context
Browse files Browse the repository at this point in the history
All the callers always use ~strage:`Configure, so just remove it.
  • Loading branch information
samoht committed Jun 29, 2023
1 parent d41ca77 commit 719d690
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/functoria/key.ml
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,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 @@ -239,7 +239,7 @@ val merge_context : default:context -> context -> context
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

0 comments on commit 719d690

Please sign in to comment.