Class: Dotbox::CLI
- Inherits:
-
Thor
- Object
- Thor
- Dotbox::CLI
- Defined in:
- lib/dotbox/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.source_root ⇒ Object
58 59 60 |
# File 'lib/dotbox/cli.rb', line 58 def self.source_root ::File.dirname(::File.('../../../bin/dotbox', __FILE__)) end |
Instance Method Details
#add(*pathes) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dotbox/cli.rb', line 16 def add(*pathes) check_setup @record = Record.new pathes.each do |path| path = ::File.(path) if ::File.exists?(path) file = File.new(path) file.backup @record.add file else say "#{path} not exists." end end end |
#remove(*pathes) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/dotbox/cli.rb', line 32 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
49 50 51 52 53 54 55 56 |
# File 'lib/dotbox/cli.rb', line 49 def restore check_setup @record = Record.new @record.each do |path| file = File.new(path) file.restore end end |
#setup ⇒ Object
10 11 12 13 |
# File 'lib/dotbox/cli.rb', line 10 def setup dropbox_path = ask('Enter dropbox folder location:').strip Dotbox::Config.new(Dotbox::CONFIG_FILE, dropbox_path) end |