ocaml-indent / args.ml

let paths, debug, lines, showstate, cursor =
  let rev_paths = ref [] in
  let debug = ref false in
  let lines = ref None in
  let showstate = ref false in
  let cursor = ref None in
  Arg.parse [
    ("-debug", Arg.Set debug, "debugging");
    ("-lines", Arg.String (fun s ->
      try
        let pos = String.index s '-' in
        let (start,end_) = (int_of_string (String.sub s 0 pos),
                            int_of_string (String.sub s (pos+1) (String.length s - pos - 1))) in
        if start <= 0 || end_ <= 0 || start > end_ then
          failwith (Printf.sprintf "Wrong -lines specification: %s" s);
        lines := Some (start, end_)
      with
      | _ -> failwith (Printf.sprintf "Wrong -lines specification: %s" s)),
     "lines, ex. 10-12") ;
    ("-cursor", Arg.String (fun s ->
      try
        let pos = String.index s ':' in
        let (rows,cols) = (int_of_string (String.sub s 0 pos),
                           int_of_string (String.sub s (pos+1) (String.length s - pos - 1))) in
        if rows <= 0 || cols < 0 then
          failwith (Printf.sprintf "Wrong -cursor specification: %s" s);
        cursor := Some (rows, cols)
      with
      | _ -> failwith (Printf.sprintf "Wrong -cursor specification: %s" s)),
     "cursor position, ex. 10:12") ;
    ("-show-state", Arg.Set showstate, "show state at the last");
  ] (fun s -> rev_paths := s :: !rev_paths) "indent paths";
  let paths = List.rev !rev_paths in
  let paths = if paths = [] then [""] else paths in (* CR jfuruse: ugly *)
  begin match paths, !lines with
  | [], _ -> assert false
  | [_], _ -> ()
  | _, Some _ -> failwith "Region can be specified with at most one file"
  | _ -> ()
  end;
  paths, !debug, !lines, !showstate, !cursor
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.