@@ -224,17 +224,15 @@ module List_files = struct
224224 entries;
225225 ()
226226
227- (* sub-command to sample a directory *)
227+ type params = { abs : bool [@ default false ] (* * show absolute paths *) }
228+ [@@ deriving subliner ]
229+
228230 let cmd =
229- let open Cmdliner in
230- let abs =
231- Arg. (
232- value & opt ~vopt: true bool false
233- & info [ " abs" ] ~doc: " show absolute paths" )
234- in
235231 let doc = " list benchmark result files" in
236- let aux abs () = main ~abs () in
237- Cmd. v (Cmd. info ~doc " list-files" ) Term. (const aux $ abs $ const () )
232+ Cmdliner.Cmd. v
233+ (Cmdliner.Cmd. info ~doc " list-files" )
234+ Cmdliner.Term. (
235+ const (fun p -> main ~abs: p.abs () ) $ params_cmdliner_term () )
238236end
239237
240238module Show = struct
@@ -274,22 +272,19 @@ module Plot = struct
274272 Cactus_plot. show p;
275273 () )
276274
277- (* sub-command for showing results *)
275+ type params = { file : string [@ pos 0 ] [@ docv "FILE" ] (* * file to read *) }
276+ [@@ deriving subliner ]
277+
278+ let run (p : params ) debug =
279+ catch_err @@ fun () ->
280+ Misc. setup_logs debug;
281+ main p.file
282+
278283 let cmd =
279- let open Cmdliner in
280- let file =
281- Arg. (
282- required
283- & pos 0 (some string ) None
284- & info [] ~docv: " FILE" ~doc: " file to read" )
285- and debug = Logs_cli. level () in
286- let aux debug file =
287- catch_err @@ fun () ->
288- Misc. setup_logs debug;
289- main file
290- in
291284 let doc = " plot benchmark results" in
292- Cmd. v (Cmd. info ~doc " plot" ) Term. (const aux $ debug $ file)
285+ Cmdliner.Cmd. v
286+ (Cmdliner.Cmd. info ~doc " plot" )
287+ Cmdliner.Term. (const run $ params_cmdliner_term () $ Logs_cli. level () )
293288end
294289
295290(* * {2 Sample} *)
335330(* * {2 Show directories} *)
336331
337332module Dir = struct
338- type which = Config | State
339-
340- let which_conv = Cmdliner.Arg. (enum [ " config" , Config ; " state" , State ])
333+ type which = Config | State [@@ deriving subliner_enum ]
341334
342335 let run c =
343336 catch_err @@ fun () ->
@@ -347,14 +340,10 @@ module Dir = struct
347340 | State -> Misc. data_dir () );
348341 ()
349342
350- (* sub-command for showing results *)
351343 let cmd =
352344 let open Cmdliner in
353345 let which =
354- Arg. (
355- required
356- & pos 0 (some which_conv) None
357- & info ~doc: " directory to list (config|state)" [] )
346+ Arg. (required & pos 0 (some (which_cmdliner_conv () )) None & info [] )
358347 in
359348 let doc =
360349 " show directories where benchpress stores its state (config|state)"
@@ -365,20 +354,27 @@ end
365354(* * {2 Check config} *)
366355
367356module Check_config = struct
368- let run debug with_default f =
357+ type params = {
358+ files : string list ; [@ pos_all] [@ default []] (* * file(s) to check *)
359+ with_default : bool ; [@ default false ] [@ names [ " d" ; " default" ]]
360+ (* * combine with the default config file(s) *)
361+ }
362+ [@@ deriving subliner ]
363+
364+ let run (p : params ) debug =
369365 catch_err @@ fun () ->
370366 Misc. setup_logs debug;
371367 let default_file = Misc. default_config () in
372368 let f =
373- if f = [] then
369+ if p.files = [] then
374370 if Sys. file_exists default_file then
375371 [ default_file ]
376372 else
377373 []
378- else if with_default && Sys. file_exists default_file then
379- Misc. default_config () :: f
374+ else if p. with_default && Sys. file_exists default_file then
375+ Misc. default_config () :: p.files
380376 else
381- f
377+ p.files
382378 in
383379 let l = Stanza. parse_files f in
384380 Format. printf " @[<v>%a@]@." Stanza. pp_l l;
@@ -387,39 +383,31 @@ module Check_config = struct
387383 ()
388384
389385 let cmd =
390- let open Cmdliner in
391- let files =
392- Arg. (value & pos_all string [] & info [] ~doc: " file(s) to check" )
393- and debug = Logs_cli. level ()
394- and with_default =
395- Arg. (
396- value & opt bool false
397- & info [ " d" ; " default" ] ~doc: " combine with the default config file(s)" )
398- in
399386 let doc = " parse and print configuration file(s)" in
400- let aux debug with_default files () = run debug with_default files in
401- Cmd. v
402- (Cmd. info ~doc " check-config" )
403- Term. (const aux $ debug $ with_default $ files $ const () )
387+ Cmdliner.Cmd. v
388+ (Cmdliner.Cmd. info ~doc " check-config" )
389+ Cmdliner.Term. (const run $ params_cmdliner_term () $ Logs_cli. level () )
404390end
405391
406392(* * {2 See prover(s)} *)
407393
408394module Prover_show = struct
409- let run (log_lvl , defs ) names =
395+ type params = { names : string list [@ pos_all] [@ default []] }
396+ [@@ deriving subliner ]
397+
398+ let run (p : params ) (log_lvl , defs ) =
410399 Misc. setup_logs log_lvl;
411400 catch_err @@ fun () ->
412- let l = CCList. map (Definitions. find_prover' defs) names in
401+ let l = CCList. map (Definitions. find_prover' defs) p. names in
413402 Format. printf " @[<v>%a@]@." (Misc. pp_list Prover. pp) l;
414403 ()
415404
416405 let cmd =
417- let open Cmdliner in
418406 let doc = " show definitions of given prover(s)" in
419- let names = Arg. (value & pos_all string [] & info [] ) in
420- Cmd. v
421- ( Cmd. info ~doc " show-prover " )
422- Term. ( const run $ Bin_utils. definitions_term $ names )
407+ Cmdliner.Cmd. v
408+ ( Cmdliner. Cmd.info ~doc " show-prover " )
409+ Cmdliner.Term. (
410+ const run $ params_cmdliner_term () $ Bin_utils. definitions_term )
423411end
424412
425413(* * {2 List provers} *)
@@ -435,30 +423,31 @@ module Prover_list = struct
435423 ()
436424
437425 let cmd =
438- let open Cmdliner in
439426 let doc = " list prover(s) defined in config" in
440- Cmd. v
441- (Cmd. info ~doc " list-prover" )
442- Term. (const run $ Bin_utils. definitions_term)
427+ Cmdliner. Cmd. v
428+ (Cmdliner. Cmd. info ~doc " list-prover" )
429+ Cmdliner. Term. (const run $ Bin_utils. definitions_term)
443430end
444431
445432(* * {2 Show Task} *)
446433
447434module Task_show = struct
448- let run (log_lvl , defs ) names =
435+ type params = { names : string list [@ pos_all] [@ default []] }
436+ [@@ deriving subliner ]
437+
438+ let run (p : params ) (log_lvl , defs ) =
449439 Misc. setup_logs log_lvl;
450440 catch_err @@ fun () ->
451- let l = CCList. map (Definitions. find_task' defs) names in
441+ let l = CCList. map (Definitions. find_task' defs) p. names in
452442 Format. printf " @[<v>%a@]@." (Misc. pp_list Task. pp) l;
453443 ()
454444
455445 let cmd =
456- let open Cmdliner in
457446 let doc = " show definitions of given task(s)" in
458- let names = Arg. (value & pos_all string [] & info [] ) in
459- Cmd. v
460- ( Cmd. info ~doc " show-task " )
461- Term. ( const run $ Bin_utils. definitions_term $ names )
447+ Cmdliner.Cmd. v
448+ ( Cmdliner. Cmd.info ~doc " show-task " )
449+ Cmdliner.Term. (
450+ const run $ params_cmdliner_term () $ Bin_utils. definitions_term )
462451end
463452
464453(* * {2 List Tasks} *)
@@ -474,30 +463,29 @@ module Task_list = struct
474463 ()
475464
476465 let cmd =
477- let open Cmdliner in
478466 let doc = " list task(s) defined in config" in
479- Cmd. v
480- (Cmd. info ~doc " list-task" )
481- Term. (const run $ Bin_utils. definitions_term)
467+ Cmdliner. Cmd. v
468+ (Cmdliner. Cmd. info ~doc " list-task" )
469+ Cmdliner. Term. (const run $ Bin_utils. definitions_term)
482470end
483471
484472(* * {2 Convert results to Sql} *)
485473
486474module Sql_convert = struct
487- let run defs files = catch_err @@ fun () -> Sql_res. run defs files
475+ type params = {
476+ files : string list ; [@ pos_all] [@ non_empty] [@ docv " FILES" ]
477+ (* * files to read *)
478+ }
479+ [@@ deriving subliner ]
480+
481+ let run (p : params ) defs = catch_err @@ fun () -> Sql_res. run defs p.files
488482
489- (* sub-command for showing results *)
490483 let cmd =
491- let open Cmdliner in
492- let files =
493- Arg. (
494- non_empty & pos_all string []
495- & info [] ~docv: " FILES" ~doc: " files to read" )
496- in
497484 let doc = " convert result(s) into sqlite files" in
498- Cmd. v
499- (Cmd. info ~doc " sql-convert" )
500- Term. (const run $ Bin_utils. definitions_term $ files)
485+ Cmdliner.Cmd. v
486+ (Cmdliner.Cmd. info ~doc " sql-convert" )
487+ Cmdliner.Term. (
488+ const run $ params_cmdliner_term () $ Bin_utils. definitions_term)
501489end
502490
503491(* * {2 Main: Parse CLI} *)
0 commit comments