1-- 2-- Copyright (c) 2014-15 John Marino <draco@marino.st> 3-- 4-- Permission to use, copy, modify, and distribute this software for any 5-- purpose with or without fee is hereby granted, provided that the above 6-- copyright notice and this permission notice appear in all copies. 7-- 8-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15-- 16 17with Ada.Text_IO; 18with Ada.Command_Line; 19with Transactions; 20 21procedure slider is 22 23 package CL renames Ada.Command_Line; 24 package TIO renames Ada.Text_IO; 25 26 SVER : constant String := "2.06"; 27 28 procedure echo_usage; 29 30 procedure echo_usage is 31 DASH : constant String (1 .. 47) := (others => '='); 32 begin 33 TIO.New_Line; 34 TIO.Put_Line (DASH); 35 TIO.Put_Line (" HAMMER file system time slider utility " & SVER); 36 TIO.Put_Line (DASH); 37 TIO.Put_Line (" Copyright (C) 2014-2015 John R. Marino"); 38 TIO.New_Line; 39 TIO.New_Line; 40 TIO.Put_Line ("Usage: slider file [save-target]"); 41 TIO.Put_Line ("-or- slider existing-directory [save-target]"); 42 TIO.New_Line; 43 TIO.Put_Line ("This tool enables the user to browse through all " & 44 "available versions of the"); 45 TIO.Put_Line ("given file stored in HAMMER history, view differences " & 46 "between two versions,"); 47 TIO.Put_Line ("replace the current version with any previous version," & 48 " restore a deleted file,"); 49 TIO.Put_Line ("and save any previous or deleted version to a new " & 50 "file."); 51 TIO.New_Line; 52 TIO.Put_Line ("If slider is passed the path of an existing directory, " & 53 "the history of that"); 54 TIO.Put_Line ("directory will be searched for all deleted files and " & 55 "subdirectories that can"); 56 TIO.Put_Line ("be restored, along with the option to restore them."); 57 TIO.New_Line; 58 end echo_usage; 59 60begin 61 62 if CL.Argument_Count < 1 or CL.Argument_Count > 2 then 63 echo_usage; 64 else 65 if CL.Argument (1) = "-h" or 66 CL.Argument (1) = "--help" or 67 CL.Argument (1) = "-v" or 68 CL.Argument (1) = "--version" 69 then 70 echo_usage; 71 else 72 if CL.Argument_Count = 1 then 73 Transactions.launch (CL.Argument (1), "", False); 74 else 75 Transactions.launch (CL.Argument (1), CL.Argument (2), True); 76 end if; 77 end if; 78 end if; 79 80end slider; 81