Class: FackUp::CLI
- Inherits:
-
Thor
- Object
- Thor
- FackUp::CLI
- Defined in:
- lib/fackup/cli.rb
Instance Method Summary collapse
- #add(*files) ⇒ Object
- #backup(file = File.join(Dir.home, 'fackup_backup.img')) ⇒ Object
- #delete(*patterns) ⇒ Object
- #list(image = nil) ⇒ Object
- #restore(image) ⇒ Object
- #version ⇒ Object
Instance Method Details
#add(*files) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/fackup/cli.rb', line 36 def add (*files) files.each {|file| if File.directory?(file) if [:recursive] Dir[File.join(file, '**', '*')].each {|f| next unless File.file?(f) unless DB << f say '* ', :red say "Can't add #{file}, unknown error." end } else say '* ', :red say "#{file} is a directory." end elsif File.file?(file) unless DB << file say '* ', :red say "Can't add #{file}, unknown error." end else say '* ', :red say "Can't add #{file}, unknown format." end } end |
#backup(file = File.join(Dir.home, 'fackup_backup.img')) ⇒ Object
78 79 80 |
# File 'lib/fackup/cli.rb', line 78 def backup (file=File.join(Dir.home, 'fackup_backup.img')) FackUp.backup(file) end |
#delete(*patterns) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/fackup/cli.rb', line 65 def delete (*patterns) patterns.map! {|pattern| File.(pattern) } DB.each {|file| patterns.each {|pattern| DB.delete(file) if File.fnmatch?(pattern, file) } } end |
#list(image = nil) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/fackup/cli.rb', line 90 def list (image=nil) if image and File.exists?(image) FackUp::Image.new(image, 'r', true) {|img| img.each {|file| puts file.name } } else DB.each {|file| puts file } if File.exists?(DB.path) end end |
#restore(image) ⇒ Object
85 86 87 |
# File 'lib/fackup/cli.rb', line 85 def restore (image) FackUp.send(([:force] ? :restore_f : :restore), image) end |