Class: Ssync::Command

Inherits:
Thor
  • Object
show all
Includes:
Helpers
Defined in:
lib/ssync/command.rb

Instance Method Summary collapse

Methods included from Helpers

#aquire_lock!, #ask, #config_exists?, #config_path, #create_homedir!, #default_config_path, #display, #display_error, #exit_with_error!, #lock_path, #read_config, #read_default_config, #ssync_filename, #ssync_homedir, #write_config!, #write_default_config!

Instance Method Details

#setupObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ssync/command.rb', line 13

def setup
  %w{find xargs openssl}.each do |util|
    e! "You do not have '#{util}' installed on your operating system." if `which #{util}`.empty?
  end

  if options.bucket?
    e! "The S3 bucket config for '#{options.bucket}' does not exist." unless config_exists?(config_path(options.bucket))
    write_default_config(options.bucket)
  end
  aquire_lock! { Ssync::Setup.run! }
end

#syncObject



30
31
32
33
34
35
36
37
# File 'lib/ssync/command.rb', line 30

def sync
  unless config_exists?(default_config_path) || config_exists?
    e! "Cannot run the sync, there is no Ssync configuration, try 'ssync setup' to create one first."
  end

  write_default_config(options.bucket) if options.bucket?
  aquire_lock! { Ssync::Sync.run!(options) }
end

#versionObject



40
41
42
# File 'lib/ssync/command.rb', line 40

def version
  puts "Ssync #{Ssync::VERSION}"
end