Skip to content

Commit

Permalink
fixup! proposal rework of relop flag
Browse files Browse the repository at this point in the history
  • Loading branch information
rjbou committed Oct 25, 2024
1 parent dd8302e commit d3096a4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 22 deletions.
1 change: 0 additions & 1 deletion master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,5 @@ users)
## opam-solver

## opam-format
* `OpamFomula`: export `string_of_relop` [#6197 @mbarbin]

## opam-core
31 changes: 15 additions & 16 deletions src/client/opamAdminCommand.ml
Original file line number Diff line number Diff line change
Expand Up @@ -832,21 +832,20 @@ let check_command cli =

let compare_versions_command_doc = "Compare two package versions"
let compare_versions_command cli =
let operator : OpamFormula.relop option Term.t =
let make_flag (relop : OpamFormula.relop) =
let flag_name =
match relop with
| `Eq -> "eq"
| `Neq -> "neq"
| `Geq -> "geq"
| `Gt -> "gt"
| `Leq -> "leq"
| `Lt -> "lt"
in
let doc = Printf.sprintf "assert V0 %s V1" (OpamFormula.string_of_relop relop) in
OpamArg.(cli_from cli2_4), Some relop, [ flag_name ], doc
in
OpamArg.mk_vflag ~cli None (List.map make_flag OpamFormula.all_relop)
let relop_flag =
let make_flag (relop, name) =
let doc =
Printf.sprintf "assert V0 %s V1" (OpamFormula.string_of_relop relop)
in
OpamArg.(cli_from cli2_4), Some relop, [ name ], doc
in
let relops =
List.map make_flag
[ `Eq, "eq" ; `Neq, "neq" ;
`Geq, "geq" ; `Gt, "gt" ;
`Leq, "leq" ; `Lt, "lt" ]
in
OpamArg.mk_vflag ~cli None relops
in
let version_arg n =
let doc =
Expand Down Expand Up @@ -893,7 +892,7 @@ let compare_versions_command cli =
else `False)
in
OpamArg.mk_command ~cli OpamArg.(cli_from cli2_4) command ~doc ~man
Term.(const cmd $ version_arg 0 $ version_arg 1 $ operator)
Term.(const cmd $ version_arg 0 $ version_arg 1 $ relop_flag)

let pattern_list_arg =
OpamArg.arg_list "PATTERNS"
Expand Down
2 changes: 0 additions & 2 deletions src/format/opamFormula.ml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

type relop = [`Eq|`Neq|`Geq|`Gt|`Leq|`Lt]

let all_relop = [ `Eq ; `Neq ; `Geq ; `Gt ; `Leq ; `Lt ]

let neg_relop = function
| `Eq -> `Neq
| `Neq -> `Eq
Expand Down
3 changes: 0 additions & 3 deletions src/format/opamFormula.mli
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ type relop = OpamParserTypes.FullPos.relop_kind (* = [ `Eq | `Neq | `Geq | `Gt |

val compare_relop : relop -> relop -> int

(** A list containing each available operator once. *)
val all_relop : relop list

(** Returns a string representing the operator in infix syntax, as
used in opam files (">", "=", etc.) *)
val string_of_relop : relop -> string
Expand Down

0 comments on commit d3096a4

Please sign in to comment.