Sha256: eea5140dc05bb13fe7bf708f7e0c6e3a8d08dd1d71f746e5c3ef69612f552d52

Contents?: true

Size: 1.52 KB

Versions: 9

Compression:

Stored size: 1.52 KB

Contents

require "shelly/cli/command"

module Shelly
  module CLI
    class File < Command
      namespace :file
      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], "file 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], "file 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

9 entries across 9 versions & 1 rubygems

Version Path
shelly-0.1.35 lib/shelly/cli/file.rb
shelly-0.1.34 lib/shelly/cli/file.rb
shelly-0.1.34.pre lib/shelly/cli/file.rb
shelly-0.1.33 lib/shelly/cli/file.rb
shelly-0.1.32 lib/shelly/cli/file.rb
shelly-0.1.31 lib/shelly/cli/file.rb
shelly-0.1.30 lib/shelly/cli/file.rb
shelly-0.1.29 lib/shelly/cli/file.rb
shelly-0.1.28 lib/shelly/cli/file.rb