12345678910111213141516171819202122232425262728293031323334353637383940(**************************************************************************)(* *)(* OCamlFormat *)(* *)(* Copyright (c) Facebook, Inc. and its affiliates. *)(* *)(* This source code is licensed under the MIT license found in *)(* the LICENSE file in the root directory of this source tree. *)(* *)(**************************************************************************)typet={lower:int;upper:int;whole:bool}letmake?rangesource=letlines_nb=List.length@@String.split_linessourceinmatchrangewith|Some(lower,upper)when1<=lower&&lower<=upper&&upper<=lines_nb+1->(* the last line of the buffer (lines_nb + 1) should be valid *)letwhole=lower=1&&upper>=lines_nbin{lower;upper;whole}|_->{lower=1;upper=lines_nb;whole=true}letgett=(t.lower,t.upper)letis_wholet=t.wholeletconv=letopenCmdlinerinletpair_conv=Arg.(pair~sep:'-'intint)inletparsex=let+range=Arg.conv_parserpair_convxinOk(make~range)inletppfsx=matchx"this string is not important"with|{whole=true;_}->Format.fprintffs"<whole input>"|{lower;upper;_}->Arg.conv_printerpair_convfs(lower,upper)inArg.conv(parse,pp)