Sha256: 05724d76a5a04a5f1ed3171bfc1a1666c688cb4287ef01501dc6c6dd03ce43c1

Contents?: true

Size: 966 Bytes

Versions: 3

Compression:

Stored size: 966 Bytes

Contents

# frozen_string_literal: true

require_relative "../../../boilercode"

module Boilercode
  module Commands
    class Drive
      class Upload < Boilercode::Command
        def initialize(options)
          @options = options
        end

        def execute(input: $stdin, output: $stdout)
          res = file_client.upload
          if res.code == 201
            response = parse_json(res)
            puts pastel.green "Upload successful!\n"
            puts pastel.green response.url
          else
            puts pastel.red "Upload failed!"

            puts pastel.red res.body
          end
        end

        def file_client
          local_file_path = ask("Enter the path to the file you want to upload: ")
          remote_folder_path = ask("Enter the path to the folder you want to upload to: (optional)")
          @file_client ||= Boilercode::FileClient.new(local_file_path, folder_path: remote_folder_path)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
boilercode-0.1.2 lib/boilercode/commands/drive/upload.rb
boilercode-0.1.1 lib/boilercode/commands/drive/upload.rb
boilercode-0.1.0 lib/boilercode/commands/drive/upload.rb