fackup 0.0.1.1 → 0.0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fackup.rb +1 -1
- data/lib/fackup/cli.rb +22 -2
- metadata +2 -2
data/lib/fackup.rb
CHANGED
data/lib/fackup/cli.rb
CHANGED
@@ -30,14 +30,21 @@ module FackUp
|
|
30
30
|
puts "fackup v#{FackUp::VERSION}"
|
31
31
|
end
|
32
32
|
|
33
|
-
desc 'add FILE... [OPTIONS]', 'add
|
33
|
+
desc 'add FILE... [OPTIONS]', 'add files to backup'
|
34
34
|
method_option :recursive, aliases: '-r', type: :boolean, default: false,
|
35
35
|
desc: 'Add files in directories recursively'
|
36
36
|
def add (*files)
|
37
37
|
files.each {|file|
|
38
38
|
if File.directory?(file)
|
39
39
|
if options[:recursive]
|
40
|
-
|
40
|
+
Dir[File.join(file, '**', '*')].each {|f|
|
41
|
+
next unless File.file?(f)
|
42
|
+
|
43
|
+
unless DB << f
|
44
|
+
say '* ', :red
|
45
|
+
say "Can't add #{file}, unknown error."
|
46
|
+
end
|
47
|
+
}
|
41
48
|
else
|
42
49
|
say '* ', :red
|
43
50
|
say "#{file} is a directory."
|
@@ -54,6 +61,19 @@ module FackUp
|
|
54
61
|
}
|
55
62
|
end
|
56
63
|
|
64
|
+
desc 'delete PATTERN...', 'delete files from backup, it supports wildcards'
|
65
|
+
def delete (*patterns)
|
66
|
+
patterns.map! {|pattern|
|
67
|
+
File.expand_path(pattern)
|
68
|
+
}
|
69
|
+
|
70
|
+
DB.each {|file|
|
71
|
+
patterns.each {|pattern|
|
72
|
+
DB.delete(file) if File.fnmatch?(pattern, file)
|
73
|
+
}
|
74
|
+
}
|
75
|
+
end
|
76
|
+
|
57
77
|
desc 'backup [FILE]', 'backup files'
|
58
78
|
def backup (file=File.join(Dir.home, 'fackup_backup.img'))
|
59
79
|
FackUp.backup(file)
|