mirror of
https://github.com/comby-tools/comby.git
synced 2024-08-16 16:50:37 +03:00
put no rg output behind debug flag
This commit is contained in:
parent
55c793f48f
commit
ed43b4fc63
@ -692,11 +692,14 @@ let ripgrep_file_filters specifications args : string list =
|
||||
in
|
||||
let result = Ripgrep.run ~pattern:regex ~args in
|
||||
match result with
|
||||
| Ok result ->
|
||||
| Ok Some result ->
|
||||
if debug then Format.printf "Ripgrep result: %s@." @@ String.concat ~sep:"\n" result;
|
||||
result
|
||||
| Ok None ->
|
||||
if debug then Format.printf "No ripgrep results, no files to process. Exiting 0.";
|
||||
exit 0
|
||||
| Error e ->
|
||||
Format.eprintf "%s@." (Error.to_string_hum e);
|
||||
if debug then Format.eprintf "%s@." (Error.to_string_hum e);
|
||||
exit 1
|
||||
|
||||
let create
|
||||
|
@ -21,7 +21,8 @@ let run ~pattern ~args =
|
||||
Lwt_process.with_process_in lwt_command (fun proc ->
|
||||
recv proc >>= fun result ->
|
||||
proc#status >>= function
|
||||
| WEXITED v when v = 1 -> return (Ok None) (* no matches *)
|
||||
| WEXITED v when v <> 0 -> return @@ Or_error.errorf "Error executing rg, exit status %d." v
|
||||
| _ -> return (Ok (String.split ~on:'\n' result |> List.filter ~f:(String.(<>) ""))))
|
||||
| _ -> return (Ok (Some (String.split ~on:'\n' result |> List.filter ~f:(String.(<>) "")))))
|
||||
in
|
||||
try Lwt_main.run (f ()) with Sys.Break -> exit 0
|
||||
|
@ -3,4 +3,4 @@ open Core
|
||||
(* [run pattern args] accepts a [pattern] and list of extra ripgrep-compatible
|
||||
arguments [args], for example, ["-g"; "*.go"; "-g"; "*.ts"]. Returns a list
|
||||
of files if the commands succeeds. *)
|
||||
val run : pattern:string -> args:string list -> string list Or_error.t
|
||||
val run : pattern:string -> args:string list -> string list option Or_error.t
|
||||
|
Loading…
Reference in New Issue
Block a user