Sha256: 15301268987809454eb452d0bdd53c080958185fbb1e7d97f01569c7dcdbf229

Contents?: true

Size: 1.51 KB

Versions: 21

Compression:

Stored size: 1.51 KB

Contents

require "shelly/cli/command"

module Shelly
  module CLI
    class Files < Command
      namespace :files
      include Helpers

      before_hook :logged_in?, :only => [:upload, :download]
      before_hook :require_rsync, :only => [:upload, :download]
      class_option :cloud, :type => :string, :aliases => "-c", :desc => "Specify cloud"

      desc "upload PATH", "Upload files to persistent data storage"
      def upload(path)
        app = multiple_clouds(options[:cloud], "upload #{path}")
        app.upload(path)
      rescue Client::ConflictException
        say_error "Cloud #{app} is not running. Cannot upload files."
      end

      desc "download [SOURCE_PATH] [DEST_PATH]", "Download files from persistent data storage"
      long_desc %{
        Download files from persistent data storage.\n
        SOURCE_PATH - optional source directory or file.\n
        DEST_PATH - optional destination where files should be saved. By default is current working directory.
      }
      def download(relative_source = ".", destination = ".")
        app = multiple_clouds(options[:cloud], "download #{relative_source} #{destination}")
        app.download(relative_source, destination)
      rescue Client::ConflictException
        say_error "Cloud #{app} is not running. Cannot download files."
      end

      no_tasks do
        def require_rsync
          unless command_exists?("rsync")
            say_error "You need to install rsync in order to upload and download files"
          end
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
shelly-0.1.27 lib/shelly/cli/files.rb
shelly-0.1.26 lib/shelly/cli/files.rb
shelly-0.1.25 lib/shelly/cli/files.rb
shelly-0.1.24 lib/shelly/cli/files.rb
shelly-0.1.24.pre2 lib/shelly/cli/files.rb
shelly-0.1.24.pre lib/shelly/cli/files.rb
shelly-0.1.23 lib/shelly/cli/files.rb
shelly-0.1.22 lib/shelly/cli/files.rb
shelly-0.1.21 lib/shelly/cli/files.rb
shelly-0.1.21.pre lib/shelly/cli/files.rb
shelly-0.1.20 lib/shelly/cli/files.rb
shelly-0.1.19 lib/shelly/cli/files.rb
shelly-0.1.18 lib/shelly/cli/files.rb
shelly-0.1.17 lib/shelly/cli/files.rb
shelly-0.1.16 lib/shelly/cli/files.rb
shelly-0.1.15 lib/shelly/cli/files.rb
shelly-0.1.14 lib/shelly/cli/files.rb
shelly-0.1.13 lib/shelly/cli/files.rb
shelly-0.1.12 lib/shelly/cli/files.rb
shelly-0.1.11 lib/shelly/cli/files.rb