Class: DropboxSync::CLI
- Inherits:
-
Thor
- Object
- Thor
- DropboxSync::CLI
- Defined in:
- lib/dropbox_sync/cli.rb
Instance Method Summary collapse
- #destroy(name) ⇒ Object
- #help ⇒ Object
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #list ⇒ Object
- #setup ⇒ Object
- #sync(path, name = nil) ⇒ Object
- #unsync(name) ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
8 9 10 11 |
# File 'lib/dropbox_sync/cli.rb', line 8 def initialize(*) super setup_infrastructure! end |
Instance Method Details
#destroy(name) ⇒ Object
38 39 40 41 42 |
# File 'lib/dropbox_sync/cli.rb', line 38 def destroy(name) entry = DropboxSync::Entry[name] entry.destroy! shell.say "#{entry.name} is now deleted from Dropbox." end |
#help ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/dropbox_sync/cli.rb', line 69 def help(*) shell.say "Dropbox Sync command line tool - by Willem van Bergen." shell.say shell.say "This tool will create symlinks for files and directories you provide in your Dropbox folder. " shell.say "This will synchronize it with Dropbox. You can then easily recreate the setup on a different " shell.say "machine by running 'dropbox-sync setup'." shell.say shell.say "Wait until all files are synced, and then quit Dropbox before using this tool." shell.say super end |
#list ⇒ Object
15 16 17 18 19 |
# File 'lib/dropbox_sync/cli.rb', line 15 def list DropboxSync::Entry.each do |entry| shell.say entry.to_s end end |
#setup ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/dropbox_sync/cli.rb', line 45 def setup DropboxSync::Entry.each do |entry| shell.say "#{entry.name}" if entry.applied? shell.say " - Syncing is already set up." elsif entry.applyable? if entry.target_exist? entry.backup_target! shell.say " - Backed up current version of #{entry.path} as #{entry.backup_path}." end entry.apply! shell.say " - Dropbox version moved to #{entry.target_path}." shell.say " - Created link #{entry.sync_path} to enable dropbox syncing." else shell.say " - Something is off with this entry!" end end end |
#sync(path, name = nil) ⇒ Object
22 23 24 |
# File 'lib/dropbox_sync/cli.rb', line 22 def sync(path, name = nil) DropboxSync::Entry.create(name || File.basename(path), path) end |
#unsync(name) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/dropbox_sync/cli.rb', line 27 def unsync(name) entry = DropboxSync::Entry[name] if entry.applied? entry.unapply! shell.say "#{entry.name} is now no longer syncing with Dropbox." else raise "Can only unsync entries that are set up correctly!" end end |