123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234open!CoremoduleTime=Time_float_unixincludeCsv_param_intfmoduleT=structincludeCommand.Paramletfile_stdin_anon=Csv_common.Or_file.anonletfile_stdin_flag=Csv_common.Or_file.flagletfiles=anon(sequence("filename"%:Filename_unix.arg_type))(* flags *)letreverse=flag"-reverse"no_arg~doc:" reverse sorting order"~aliases:["--reverse"];;letfield'~aliases=flag"-field"(requiredstring)~doc:"<field> field name to sort on"~aliases;;letfield=field'~aliases:["--field"]lettime_field=flag"-time-field"(requiredstring)~doc:"<field> field with times for snapping to grid"~aliases:["--time-field"];;letstart_time=flag"-start"(requiredTime.arg_type)~doc:"<time> time to start grid"~aliases:["--start"];;letstop_time=flag"-stop"(requiredTime.arg_type)~doc:"<time> time to stop grid"~aliases:["--stop"];;letgrid_step=flag"-step"(requiredTime.Span.arg_type)~doc:"<span> time span for grid step"~aliases:["--step"];;letmax_width=flag"-limit-width-to"(optionalint)~doc:" maximum column width in output";;letprefer_split_on_spaces=flag_optional_with_default_doc"-prefer-split-on-spaces"bool[%sexp_of:bool]~default:true~doc:"BOOL prefer splitting lines on spaces rather than mid-word";;letregexp_arg=Command.Arg_type.createRe2.create_exnletregexp=flag"-regexp"(requiredregexp_arg)~doc:"<regexp> regexp to search for (re2 style)"~aliases:["--regexp"];;letinvert=flag"-invert-match"no_arg~doc:" Invert the sense of matching, to select non-matching lines."~aliases:["-v"];;letskip_lines=flag"-skip-lines"(optionalint)~doc:"<nr-of-lines> drop this many lines from the beginning of the input"~aliases:["--skip-lines"];;letdefault_sep=','letdefault_space=2letsep_arg=Arg_type.create(funs->ifString.(=)s"\\t"then'\t'elseifString.lengths<>1thenfailwithf"Delimiter <%s> not 1 char!"s()elses.[0]);;letsep=flag"-sep"~aliases:["-d";"-delim";"--sep"](optional_with_defaultdefault_sepsep_arg)~doc:(sprintf"CHAR csv separator (default: '%c')"default_sep);;letkey_specifier=letopenCommand.Paraminflag"k"(requiredstring)~doc:"SPEC comma-separated list of fields comprising the key";;letno_header=letopenCommand.Paraminflag"-nh"no_arg~doc:" do not treat the first row as a header row"~aliases:["-no-header";"--no-header"];;letspace=letopenCommand.Paraminflag"-s"(optional_with_defaultdefault_spaceint)~doc:(sprintf"NUM how far apart to space out columns (default: '%d')"default_space);;letsuppress_header=letopenCommand.Paraminflag"-sh"no_arg~doc:" keep the header row from appearing in the output"~aliases:["-suppress-header";"--suppress-header"];;letfields_gen~doc=letopenCommand.Paraminletarg_type=Arg_type.comma_separated~strip_whitespace:truestring~allow_empty:trueinflag~aliases:["--fields"]"-fields"(optional_with_default[]arg_type)~doc;;letfields=fields_gen~doc:" named fields to extract, comma separated"letfields_backward_compat=letopenCommand.Paraminletarg_type=Arg_type.comma_separated~strip_whitespace:truestring~allow_empty:trueinflag~aliases:["-f";"--field"]"-field"(optional_with_default[]arg_type)~doc:" named fields to sort on, comma separated (outermost sort first)";;letreverse_fields=letopenCommand.Paraminletarg_type=Arg_type.comma_separated~strip_whitespace:truestring~allow_empty:trueinflag~aliases:["--reverse-fields"]"-reverse-fields"(optional_with_default[]arg_type)~doc:" fields for which to reverse the sort order";;letpop_fields=fields_gen~doc:" named fields required to count as fully populated, comma separated";;letexclude_fields=letopenCommand.Paraminflag~aliases:["--invert-match"]"-v"no_arg~doc:" exclude specified fields rather than extract them";;moduleKey_value_pair=structtypet=string*stringoptionletof_strings=matchString.splits~on:'='with|[key]->((key,None):t)|[key;value]->((key,Somevalue):t)|_->failwithf"Couldn't parse key=value pair: %s"s();;letarg_type=Arg_type.createof_stringletflagnamedesc=letopenCommand.Paraminflag("-"^name)~aliases:["--"^name](listedarg_type)~doc:(sprintf" %s attribute(s) in HTML output (e.g. \"align=center\")"desc);;endlettable_attrs=Key_value_pair.flag"table""Table"letth_attrs=Key_value_pair.flag"th""Table header"lettr_attrs=Key_value_pair.flag"tr""Table row"lettd_attrs=Key_value_pair.flag"td""Table cell"(* This could be specified through the more general table attributes above, but
[Html.Html_table] handles this attribute separately, requiring a separate
command-line option. *)letborder=letopenCommand.Paraminflag"-border"~aliases:["--border"]no_arg~doc:" Visible borders in HTML output";;endincludeTincludeApplicative.Make_let_syntax(T)(Open_on_rhs_intf)(T)