Mercurial > hg > sonic-annotator
diff repoint.sml @ 346:90169412b1a7
Merge from branch by-id
author | Chris Cannam |
---|---|
date | Thu, 18 Jul 2019 14:58:51 +0100 |
parents | ba3c0e70b5dd |
children | f09defd7040b |
line wrap: on
line diff
--- a/repoint.sml Fri Sep 14 14:55:24 2018 +0100 +++ b/repoint.sml Thu Jul 18 14:58:51 2019 +0100 @@ -38,7 +38,7 @@ authorization. *) -val repoint_version = "0.9.98" +val repoint_version = "1.1" datatype vcs = @@ -136,6 +136,7 @@ structure RepointFilenames = struct val project_file = "repoint-project.json" val project_lock_file = "repoint-lock.json" + val project_completion_file = ".repoint.point" val user_config_file = ".repoint.json" val archive_dir = ".repoint-archive" end @@ -215,6 +216,7 @@ val nonempty_dir_exists : string -> bool val project_spec_path : string -> string val project_lock_path : string -> string + val project_completion_path : string -> string val verbose : unit -> bool end = struct @@ -272,6 +274,9 @@ fun project_lock_path rootpath = project_file_path rootpath (RepointFilenames.project_lock_file) + fun project_completion_path rootpath = + project_file_path rootpath (RepointFilenames.project_completion_file) + fun trim str = hd (String.fields (fn x => x = #"\n" orelse x = #"\r") str) @@ -2420,7 +2425,14 @@ in JsonBits.save_json_to lock_file lock_json end - + +fun checkpoint_completion_file rootpath = + let val completion_file = FileBits.project_completion_path rootpath + val stream = TextIO.openOut completion_file + in + TextIO.closeOut stream + end + fun pad_to n str = if n <= String.size str then str else pad_to n (str ^ " ") @@ -2586,8 +2598,12 @@ val _ = if List.exists (fn (_, OK _) => true | _ => false) outcomes then lock_project project else OS.Process.success + val return_code = return_code_for outcomes in - return_code_for outcomes + if OS.Process.isSuccess return_code + then checkpoint_completion_file (#rootpath context) + else (); + return_code end fun load_local_project pintype = @@ -2625,18 +2641,23 @@ fun usage () = (print "\nRepoint "; version (); - print ("\nA simple manager for third-party source code dependencies.\n\n" + print ("\n A simple manager for third-party source code dependencies.\n" + ^ " http://all-day-breakfast.com/repoint/\n\n" ^ "Usage:\n\n" - ^ " repoint <command>\n\n" + ^ " repoint <command> [<options>]\n\n" ^ "where <command> is one of:\n\n" ^ " status print quick report on local status only, without using network\n" ^ " review check configured libraries against their providers, and report\n" ^ " install update configured libraries according to project specs and lock file\n" ^ " update update configured libraries and lock file according to project specs\n" - ^ " lock update lock file to match local library status\n" - ^ " archive pack up project and all libraries into an archive file\n" - ^ " (invoke as 'repoint archive target-file.tar.gz')\n" - ^ " version print the Repoint version number and exit\n\n"); + ^ " lock rewrite lock file to match local library status\n" + ^ " archive pack up project and all libraries into an archive file:\n" + ^ " invoke as 'repoint archive targetfile.tar.gz --exclude unwanted.txt'\n" + ^ " version print the Repoint version number and exit\n\n" + ^ "and <options> may include:\n\n" + ^ " --directory <dir>\n" + ^ " change to directory <dir> before doing anything; in particular,\n" + ^ " expect to find project spec file in that directory\n\n"); OS.Process.failure) fun archive target args = @@ -2647,8 +2668,26 @@ with_local_project USE_LOCKFILE (Archive.archive (target, xs)) | _ => usage () +fun handleSystemArgs args = + let fun handleSystemArgs' leftover args = + case args of + "--directory"::dir::rest => + (OS.FileSys.chDir dir; + handleSystemArgs' leftover rest) + | arg::rest => + handleSystemArgs' (leftover @ [arg]) rest + | [] => leftover + in + OK (handleSystemArgs' [] args) + handle e => ERROR (exnMessage e) + end + fun repoint args = - let val return_code = + case handleSystemArgs args of + ERROR e => (print ("Error: " ^ e ^ "\n"); + OS.Process.exit OS.Process.failure) + | OK args => + let val return_code = case args of ["review"] => review () | ["status"] => status () @@ -2660,10 +2699,9 @@ | arg::_ => (print ("Error: unknown argument \"" ^ arg ^ "\"\n"); usage ()) | _ => usage () - in - OS.Process.exit return_code; - () - end + in + OS.Process.exit return_code + end fun main () = repoint (CommandLine.arguments ())