Finished feature

This commit is contained in:
Tristan Ancelet 2024-05-26 12:39:50 -05:00
parent 91d06fa18c
commit c6f238ae01

View File

@ -22,43 +22,44 @@ Description:
search the filebucket and restore from it. search the filebucket and restore from it.
Actions: Actions:
search <term> : Search for bucket entries matching a portion of the filepath search <term> : Search for bucket entries matching a portion of the filepath
list : List all Bucket entries list : List all Bucket entries
list-files : List all files/paths that have been backed up to the bucket list-files : List all files/paths that have been backed up to the bucket
get <entry-hash> : Get the content of a specific entry (by hash) get <entry-hash> : Get the content of a specific entry (by hash)
restore <value> : Restore previous state of file stored in bucket. Value can be hash or filename/filepath restore <value> : Restore previous state of file stored in bucket. Value can be hash or filename/filepath
: Note: To restore to an alternate path you will need to provide the path via the -o flag : Note: To restore to an alternate path you will need to provide the path via the -o flag
: :
backup <file> : Backup the file to the bucket (will work relatively unless full path is provided) backup <file> : Backup the file to the bucket (will work relatively unless full path is provided)
Restore Flags: Restore Flags:
-o | --output-file <file> : Used to provide an alternate restoral path for the restore function -o | --output-file <file> : Used to provide an alternate restoral path for the restore function
Global Flags: Global Flags:
-d | --debug : Set debug flag -d | --debug : Set debug flag
-h | --help : This help message -h | --help : This help message
-b | --bucket <bucket-dir> : User specified bucket directory
Listing Filter Flags: Listing Filter Flags:
--from-date <DATE> : Filter listings from starting after this point (FORMAT: YYYY-MM-DD HH:MM:SS) --from-date <DATE> : Filter listings from starting after this point (FORMAT: YYYY-MM-DD HH:MM:SS)
: EX: : EX:
: 1. --from-date 2023-05-10 : 1. --from-date 2023-05-10
: 2. --from-date "2023-05-10 13:23" : 2. --from-date "2023-05-10 13:23"
: :
--to-date <DATE> : Filter listings from ending at this point (FORMAT: YYYY-MM-DD HH:MM:SS) --to-date <DATE> : Filter listings from ending at this point (FORMAT: YYYY-MM-DD HH:MM:SS)
: EX: : EX:
: 1. --to-date 2024-05-10 : 1. --to-date 2024-05-10
: 2. --to-date "2024-05-10 05:27" : 2. --to-date "2024-05-10 05:27"
: :
Info Format Flags: Info Format Flags:
-i | --inline : Set the info format to inline (MTIME : HASH : FILENAME) -i | --inline : Set the info format to inline (MTIME : HASH : FILENAME)
-l | --long : Set the info format to long -l | --long : Set the info format to long
: Entry [HASH]: : Entry [HASH]:
: Paths: path1,path2,...,pathn : Paths: path1,path2,...,pathn
: MTIME: YYYY-MM-DD HH:MM:SS -#### : MTIME: YYYY-MM-DD HH:MM:SS -####
: :
-c | --csv : Set the info format to csv ( MTIME,HASH,FILENAME1[;FILENAMEn] ) -c | --csv : Set the info format to csv ( MTIME,HASH,FILENAME1[;FILENAMEn] )
Author: Author:
Name: Tristan Ancelet Name: Tristan Ancelet
@ -284,6 +285,19 @@ while i < ARGV.count
usage usage
exit exit
end end
when '-b', '--bucket'
log "user provided ARGV[i.next] == #{ARGV[i.next]}"
if ARGV[i.next] != "" and not ARGV[i.next] =~ FLAG_REGEX
$CONFIG[:bucketdir]=ARGV[i.next]
log "$CONFIG[:bucketdir] was set to #{ARGV[i.next]}"
i+=2
else
puts "Flag[#{ARGV[i]}] : Argument[#{ARGV[i.next]}] : Either the argument was not provided or it was a flag"
usage
exit
end
when '--to-date', '--from-date' when '--to-date', '--from-date'
if ARGV[i.next] != "" and ARGV[i.next] =~ DATE_REGEX if ARGV[i.next] != "" and ARGV[i.next] =~ DATE_REGEX
date_matches = DATE_REGEX.match(ARGV[i.next]).named_captures.each_value.select{|val| not val.nil?}.map(&:to_i) date_matches = DATE_REGEX.match(ARGV[i.next]).named_captures.each_value.select{|val| not val.nil?}.map(&:to_i)
@ -319,6 +333,11 @@ if $CONFIG[:action] == ""
puts "Action was not provided" puts "Action was not provided"
end end
if not Dir.exist? $CONFIG[:bucketdir]
puts "BucketDir[#{$CONFIG[:bucketdir]}] Does not exist. Please check to make sure configuration is correct"
exit
end
case $CONFIG[:action] case $CONFIG[:action]
when 'search', 'get' when 'search', 'get'
if $CONFIG[:search_term] == "" if $CONFIG[:search_term] == ""