Class: Dotbox::CLI
- Inherits:
-
Thor
- Object
- Thor
- Dotbox::CLI
- Defined in:
- lib/dotbox/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add(*pathes) ⇒ Object
- #remove(*pathes) ⇒ Object
- #restore ⇒ Object
- #setup ⇒ Object
- #version ⇒ Object
Class Method Details
.source_root ⇒ Object
69 70 71 |
# File 'lib/dotbox/cli.rb', line 69 def self.source_root ::File.dirname(::File.('../../../bin/dotbox', __FILE__)) end |
Instance Method Details
#add(*pathes) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/dotbox/cli.rb', line 17 def add(*pathes) check_setup @record = Record.new pathes.each do |path| if Dir[path].empty? die "#{path} not exists." end Dir[path].each do |p| begin p = ::File.(p) file = File.new(p) file.backup @record.add file rescue => ex die ex. end end end end |
#remove(*pathes) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/dotbox/cli.rb', line 38 def remove(*pathes) check_setup @record = Record.new pathes.each do |path| path = ::File.(path) file = File.new(path) if !::File.exists?(path) die "#{path} not exists." elsif !file.backuped? die "#{path} is not backuped." end file.remove @record.remove file end end |
#restore ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/dotbox/cli.rb', line 55 def restore check_setup @record = Record.new @record.each do |path| file = File.new(path) file.restore end end |
#setup ⇒ Object
11 12 13 14 |
# File 'lib/dotbox/cli.rb', line 11 def setup dropbox_path = ask('Enter dropbox folder location:').strip Dotbox::Config.new(Dotbox::CONFIG_FILE, dropbox_path) end |