1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465openError_monadtypeoutput_format=Rowsof{separator:string;escape:[`No|`OCaml]}letrowsseparatorescape=Rows{separator;escape}lettsv=rows"\t"`Noletcsv=rows","`OCamlletclic_arg()=letopenTezos_clicinarg~doc:"Make the output script-friendly. Possible values are 'TSV' and 'CSV'."~long:"for-script"~placeholder:"FORMAT"(parameter(fun_spec->letopenLwt_result_syntaxinmatchString.lowercase_asciispecwith|"tsv"->returntsv|"csv"->returncsv|other->failwith"Cannot recognize format %S, please try 'TSV' or 'CSV'"other))letfprintf_lwtchanfmt=letopenLwt_syntaxinFormat.kasprintf(funs->protect(fun()->let*()=Lwt_io.writechansinreturn_ok_unit))fmtletoutput?(channel=Lwt_io.stdout)how_option~for_human~for_script=letopenLwt_result_syntaxinmatchhow_optionwith|None->for_human()|Some(Rows{separator;escape})->letopenFormatinlet*()=List.iter_es(funrow->fprintf_lwtchannel"%a@."(pp_print_list~pp_sep:(funfmt()->pp_print_stringfmtseparator)(funfmtcell->matchescapewith|`OCaml->fprintffmt"%S"cell|`No->pp_print_stringfmtcell))row)(for_script())inprotect(fun()->let*!()=Lwt_io.flushchannelinreturn_unit)letoutput_for_humanhow_optionfor_human=outputhow_option~for_human~for_script:(fun()->[])letoutput_row?channelhow_option~for_human~for_script=output?channelhow_option~for_human~for_script:(fun()->[for_script()])