Skip to content

Commit

Permalink
Update to cmdliner.1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterDA authored and art-w committed Feb 20, 2024
1 parent b407d3a commit aa7aa47
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 43 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Changed

- Lock files are now opened with O_CLOEXEC flag (#394, @vect0r-vicall)
- Update to cmdliner.1.1.0 (#382, @MisterDA)

# 1.6.2 (2023-06-06)

Expand Down
17 changes: 6 additions & 11 deletions bench/bench.ml
Original file line number Diff line number Diff line change
Expand Up @@ -553,13 +553,7 @@ let run filter root output seed with_metrics log_size nb_entries nb_exec json

open Cmdliner

let deprecated_info = (Term.info [@alert "-deprecated"])
let deprecated_exit = (Term.exit [@alert "-deprecated"])
let deprecated_eval_choice = (Term.eval_choice [@alert "-deprecated"])
let deprecated_pure = (Term.pure [@alert "-deprecated"])
let deprecated_default_exits = (Term.default_exits [@alert "-deprecated"])
let deprecated_env_var = (Arg.env_var [@alert "-deprecated"])
let env_var s = deprecated_env_var ("INDEX_BENCH_" ^ s)
let env_var s = Cmd.Env.info ("INDEX_BENCH_" ^ s)

let new_file =
let parse s =
Expand Down Expand Up @@ -627,7 +621,7 @@ let nb_exec =

let list_cmd =
let doc = "List all available benchmarks." in
(Term.(deprecated_pure list_benches $ const ()), deprecated_info "list" ~doc)
(Term.(const list_benches $ const ()), Cmd.info "list" ~doc)

let json_flag =
let doc = "Output the results as a json object." in
Expand Down Expand Up @@ -660,8 +654,9 @@ let cmd =
$ json_flag
$ sampling_interval
$ minimal_flag),
deprecated_info "run" ~doc ~exits:deprecated_default_exits )
Cmd.info "run" ~doc )

let () =
let choices = [ list_cmd ] in
deprecated_exit @@ deprecated_eval_choice cmd choices
let default, info = cmd in
let choices = List.map (fun (term, info) -> Cmd.v info term) [ list_cmd ] in
Stdlib.exit @@ Cmd.eval (Cmd.group ~default info choices)
8 changes: 2 additions & 6 deletions bench/replay.ml
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,6 @@ let main_term =
$ nb_ops
$ trace_data_file)

let deprecated_info = (Term.info [@alert "-deprecated"])
let deprecated_exit = (Term.exit [@alert "-deprecated"])
let deprecated_eval = (Term.eval [@alert "-deprecated"])

let () =
let man =
[
Expand All @@ -286,8 +282,8 @@ let () =
]
in
let info =
deprecated_info ~man
Cmd.info ~man
~doc:"Replay index operations done by the bootstrapping of a tezos node"
"replay-index"
in
deprecated_exit @@ deprecated_eval (main_term, info)
exit @@ Cmd.eval (Cmd.v info main_term)
2 changes: 1 addition & 1 deletion index-bench.opam
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ homepage: "https://github.com/mirage/index"
bug-reports: "https://github.com/mirage/index/issues"
depends: [
"ocaml" {>= "4.03.0"}
"cmdliner"
"cmdliner" {>= "1.1.0"}
"dune" {>= "2.7.0"}
"fmt"
"index" {= version}
Expand Down
4 changes: 2 additions & 2 deletions index.opam
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ depends: [
"fmt" {>= "0.8.5"}
"logs" {>= "0.7.0"}
"mtime" {>= "2.0.0"}
"cmdliner"
"cmdliner" {>= "1.1.0"}
"progress" {>= "0.2.1"}
"semaphore-compat" {>= "1.0.1"}
"jsonm"
"stdlib-shims"
"alcotest" {with-test}
"alcotest" {with-test & >= "1.7.0"}
"crowbar" {with-test & >= "0.2"}
"re" {with-test}
"lru" {>= "0.3.0"}
Expand Down
40 changes: 17 additions & 23 deletions src/checks.ml
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,6 @@ module Make (K : Data.Key) (V : Data.Value) (Platform : Platform_args) = struct
module Cli = struct
open Cmdliner

let deprecated_info = (Term.info [@alert "-deprecated"])
let deprecated_exit = (Term.exit [@alert "-deprecated"])
let deprecated_eval_choice = (Term.eval_choice [@alert "-deprecated"])

let reporter =
let pp_header ppf = function
| Logs.App, header ->
Expand All @@ -171,26 +167,24 @@ module Make (K : Data.Key) (V : Data.Value) (Platform : Platform_args) = struct
Logs_fmt.reporter ~pp_header ()

let main () : empty =
let default =
let default_info =
let doc = "Check and repair Index data-stores." in
deprecated_info ~doc "index-fsck"
in
Term.(ret (const (`Help (`Auto, None))), default_info)
let default = Term.(ret (const (`Help (`Auto, None)))) in
let info =
let doc = "Check and repair Index data-stores." in
Cmd.info ~doc "index-fsck"
in
let commands =
[
( Term.(Stat.term $ Log.setup_term ~reporter (module Clock)),
Cmd.info ~doc:"Print high-level statistics about the store." "stat"
);
( Term.(Integrity_check.term $ Log.setup_term ~reporter (module Clock)),
Cmd.info
~doc:"Search the store for integrity faults and corruption."
"integrity-check" );
]
in
Term.(
deprecated_eval_choice default
[
( Stat.term $ Log.setup_term ~reporter (module Clock),
deprecated_info
~doc:"Print high-level statistics about the store." "stat" );
( Integrity_check.term $ Log.setup_term ~reporter (module Clock),
deprecated_info
~doc:"Search the store for integrity faults and corruption."
"integrity-check" );
]
|> (deprecated_exit : unit result -> _));
assert false
let commands = List.map (fun (term, info) -> Cmd.v info term) commands in
exit @@ Cmd.eval (Cmd.group ~default info commands)
end

let cli = Cli.main
Expand Down

0 comments on commit aa7aa47

Please sign in to comment.