(* main.ml - Don Yang (uguu.org) 04/16/06 *) let quote_arg x = if String.contains x ' ' then if (String.get x 0) = '"' then if (String.length x) = 1 then failwith ("Error quoting string " ^ x) else x else ("\"" ^ x ^ "\"") else x;; match Array.to_list Sys.argv with argv0::"commit"::[] -> (try Commit.commit() with Failure err_msg -> print_string err_msg; print_newline(); exit 1) | argv0::cmd::args -> (try if Sys.os_type = "Unix" then let argv = Array.of_list (cmd::(Version.expand_args args)) in (flush_all(); Unix.execvp cmd argv) else let cmdline = List.fold_left (fun x y -> x ^ " " ^ y) cmd (List.map quote_arg (Version.expand_args args)) in (flush_all(); exit (Sys.command cmdline)) with Failure err_msg -> print_string err_msg; print_newline(); exit 1) | _ -> print_string ( "Commit new snapshot:\n" ^ " chii commit\n\n" ^ "Run command:\n" ^ " chii \n\n" ^ "File version syntax (used to expand ):\n" ^ " # Absolute version of \n" ^ " : file name, *, or ...\n" ^ " : yyyy-mm-dd-HH-MM-SS\n" ^ " # Relative version of \n" ^ " (1 = oldest, -1 = latest)\n" ^ " # Last version of file\n" ^ " # Files in repository root\n" ^ " # Repository directory\n\n");; exit 0;;