Skip to content

Commit

Permalink
add option --quiet for suppressing all the logs for ordinary scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
gfngfn committed Sep 8, 2024
1 parent c2fa2a7 commit 0c5513e
Show file tree
Hide file tree
Showing 11 changed files with 133 additions and 93 deletions.
2 changes: 1 addition & 1 deletion bin-saphe/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
(name saphe)
(public_name saphe)
(package saphe)
(libraries sapheMain cmdliner)
(libraries sapheMain satysfi-common cmdliner)
(preprocess no_preprocessing))
21 changes: 11 additions & 10 deletions bin-saphe/saphe.ml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let build
page_number_limit
max_repeats
show_full_path
verbose
verbosity
debug_show_bbox
debug_show_space
debug_show_block_bbox
Expand All @@ -42,7 +42,7 @@ let build
~page_number_limit
~max_repeats
~show_full_path
~verbose
~verbosity
~debug_show_bbox
~debug_show_space
~debug_show_block_bbox
Expand All @@ -56,13 +56,13 @@ let test
fpath_in
text_mode_formats_str_opt
show_full_path
verbose
verbosity
=
SapheMain.test
~fpath_in
~text_mode_formats_str_opt
~show_full_path
~verbose
~verbosity


let arg_in : string Cmdliner.Term.t =
Expand Down Expand Up @@ -110,10 +110,11 @@ let flag_full_path =
~doc:"Displays paths in full-path style"


let flag_verbose =
make_boolean_flag_spec
~flags:[ "verbose" ]
~doc:"Verbosity of logs"
let flag_verbosity : Verbosity.t Cmdliner.Term.t =
let open Cmdliner in
let verbose = (Verbosity.Verbose, Arg.info [ "verbose" ] ~doc:"Make logs verbose") in
let quiet = (Verbosity.Quiet, Arg.info [ "quiet" ] ~doc:"Disable logs other than errors and warnings") in
Arg.(value (vflag Verbosity.Normal [ verbose; quiet ]))


let flag_debug_show_bbox =
Expand Down Expand Up @@ -200,7 +201,7 @@ let command_build : unit Cmdliner.Cmd.t =
$ flag_page_number_limit
$ flag_max_repeats
$ flag_full_path
$ flag_verbose
$ flag_verbosity
$ flag_debug_show_bbox
$ flag_debug_show_space
$ flag_debug_show_block_bbox
Expand All @@ -218,7 +219,7 @@ let command_test : unit Cmdliner.Cmd.t =
$ arg_in
$ flag_text_mode
$ flag_full_path
$ flag_verbose
$ flag_verbosity
)


Expand Down
27 changes: 14 additions & 13 deletions bin/satysfi.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ let build_package
fpath_deps
text_mode_formats_str_opt
show_full_path
verbose
verbosity
=
Main.build_package
~fpath_in
~fpath_deps
~text_mode_formats_str_opt
~show_full_path
~verbose
~verbosity


let build_document
Expand All @@ -23,7 +23,7 @@ let build_document
page_number_limit
max_repeats
show_full_path
verbose
verbosity
debug_show_bbox
debug_show_space
debug_show_block_bbox
Expand All @@ -41,7 +41,7 @@ let build_document
~page_number_limit
~max_repeats
~show_full_path
~verbose
~verbosity
~debug_show_bbox
~debug_show_space
~debug_show_block_bbox
Expand All @@ -56,14 +56,14 @@ let test_package
fpath_deps
text_mode_formats_str_opt
show_full_path
verbose
verbosity
=
Main.test_package
~fpath_in
~fpath_deps
~text_mode_formats_str_opt
~show_full_path
~verbose
~verbosity


let arg_in : string Cmdliner.Term.t =
Expand Down Expand Up @@ -118,10 +118,11 @@ let flag_full_path =
~doc:"Displays paths in full-path style"


let flag_verbose =
make_boolean_flag_spec
~flags:[ "verbose" ]
~doc:"Verbosity of logs"
let flag_verbosity =
let open Cmdliner in
let verbose = (Verbosity.Verbose, Arg.info [ "verbose" ] ~doc:"Make logs verbose") in
let quiet = (Verbosity.Quiet, Arg.info [ "quiet" ] ~doc:"Disable logs other than errors and warnings") in
Arg.(value (vflag Verbosity.Normal [ verbose; quiet ]))


let flag_debug_show_bbox =
Expand Down Expand Up @@ -178,7 +179,7 @@ let command_build_document =
$ flag_page_number_limit
$ flag_max_repeats
$ flag_full_path
$ flag_verbose
$ flag_verbosity
$ flag_debug_show_bbox
$ flag_debug_show_space
$ flag_debug_show_block_bbox
Expand All @@ -197,7 +198,7 @@ let command_build_package =
$ flag_deps
$ flag_text_mode
$ flag_full_path
$ flag_verbose
$ flag_verbosity
)


Expand All @@ -217,7 +218,7 @@ let command_test_package =
$ flag_deps
$ flag_text_mode
$ flag_full_path
$ flag_verbose
$ flag_verbosity
)


Expand Down
5 changes: 5 additions & 0 deletions src-common/verbosity.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

type t =
| Verbose
| Normal
| Quiet
10 changes: 5 additions & 5 deletions src-saphe/sapheMain.ml
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ let build
~(page_number_limit : int)
~(max_repeats : int)
~(show_full_path : bool)
~(verbose : bool)
~(verbosity : Verbosity.t)
~(debug_show_bbox : bool)
~(debug_show_space : bool)
~(debug_show_block_bbox : bool)
Expand All @@ -634,7 +634,7 @@ let build
let options =
SatysfiCommand.{
show_full_path;
verbose;
verbosity;
}
in
let abspath_package_config = Constant.library_package_config_path ~dir:abspath_in in
Expand All @@ -651,7 +651,7 @@ let build
let options =
SatysfiCommand.{
show_full_path;
verbose;
verbosity;
page_number_limit;
debug_show_bbox;
debug_show_space;
Expand Down Expand Up @@ -799,7 +799,7 @@ let test
~(fpath_in : string)
~(text_mode_formats_str_opt : string option)
~(show_full_path : bool)
~(verbose : bool)
~(verbosity : Verbosity.t)
=
let res =
let open ResultMonad in
Expand All @@ -811,7 +811,7 @@ let test
let options =
SatysfiCommand.{
show_full_path;
verbose;
verbosity;
}
in
let abspath_package_config = Constant.library_package_config_path ~dir:abspath_in in
Expand Down
4 changes: 2 additions & 2 deletions src-saphe/sapheMain.mli
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ val build :
page_number_limit:int ->
max_repeats:int ->
show_full_path:bool ->
verbose:bool ->
verbosity:Verbosity.t ->
debug_show_bbox:bool ->
debug_show_space:bool ->
debug_show_block_bbox:bool ->
Expand All @@ -30,7 +30,7 @@ val test :
fpath_in:string ->
text_mode_formats_str_opt:(string option) ->
show_full_path:bool ->
verbose:bool ->
verbosity:Verbosity.t ->
unit

val cache_list : unit -> unit
23 changes: 13 additions & 10 deletions src-saphe/satysfiCommand.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,27 @@ let escape_command_line (args : string list) : string =

let make_mode_args (text_mode_formats_str_opt : string option) =
match text_mode_formats_str_opt with
| None ->
[]
| None -> []
| Some(text_mode_formats_str) -> [ "--text-mode"; text_mode_formats_str ]

| Some(text_mode_formats_str) ->
[ "--text-mode"; text_mode_formats_str ]

let make_verbosity_args (verbosity : Verbosity.t) =
match verbosity with
| Verbosity.Verbose -> [ "--verbose" ]
| Verbosity.Normal -> []
| Verbosity.Quiet -> [ "--quiet" ]


type package_build_option = {
show_full_path : bool;
verbose : bool;
verbosity : Verbosity.t;
}


let make_package_build_option_args (options : package_build_option) =
let flag b s = if b then [ s ] else [] in
List.concat [
flag options.show_full_path "--full-path";
flag options.verbose "--verbose";
if options.show_full_path then [ "--full-path" ] else [];
make_verbosity_args options.verbosity;
]


Expand All @@ -63,7 +66,7 @@ let build_package

type document_build_option = {
show_full_path : bool;
verbose : bool;
verbosity : Verbosity.t;
page_number_limit : int;
debug_show_bbox : bool;
debug_show_space : bool;
Expand All @@ -79,7 +82,7 @@ let make_document_build_option_args (options : document_build_option) =
let flag b s = if b then [ s ] else [] in
List.concat [
flag options.show_full_path "--full-path";
flag options.verbose "--verbose";
make_verbosity_args options.verbosity;
flag options.debug_show_bbox "--debug-show-bbox";
flag options.debug_show_space "--debug-show-space";
flag options.debug_show_block_bbox "--debug-show-block-bbox";
Expand Down
Loading

0 comments on commit 0c5513e

Please sign in to comment.