Sha256: 203482c9fff39f444d1b3cce0e1d8da9fd0f6c10fab6482ebebe2e7214749f9f

Contents?: true

Size: 1.77 KB

Versions: 1

Compression:

Stored size: 1.77 KB

Contents

#!/usr/bin/env ruby

# TODO
# => Try to fix spinner bug on Windows (may be a weird interaction with \r)

require 'core'

options = {}
OptionParser.new do |opts|
  opts.banner = "Usage: #{$PROGRAM_NAME} [options]"
  opts.separator Paint["\nGeneral Options: ", '#95a5a6']

  opts.on('--version', 'Show the rise version and exit') do
    puts "Rise version: #{Paint[Rise::Constants::VERSION, '#2ecc71']}"
    exit 0
  end

  opts.on('-v', '--verbose', 'Run verbosely') do |v|
    options[:verbose] = v
  end
  # directory flag
  opts.on('-d DIR', '--dir DIR', String, 'Upload files in DIR') do |d|
    options[:directory] = d unless d.nil?
  end

  opts.on('-u', '--update', 'Check if rise has a newer version and install it') do
    Rise::Util.check_for_update!
    exit 0
  end

  opts.on('-h', '--help', 'Show this help message') do
    puts opts
    exit
  end
end.parse!(ARGV)

if Rise::Util.first_run?
  Rise::Util.setup
  puts "\nPlease run the `rise` command again to upload your files."
  exit 0
end
Rise::Util.check_for_update!
result_url = ''
uploader = Rise::Transport::Uploader.new(options[:directory] || Dir.pwd)

if uploader.total_files_size > 52428800
  puts Paint["Max file size reached (#{uploader.total_files_size} > 50MB)", '#FF0000']
  exit 0
end

puts Paint['Thanks for using Rise! Your local source for serverless deployment!', '#95a5a6']

Whirly.start(spinner: 'dots', status: "Uploading files (#{uploader.total_files} total files)") do
  beginning_time = Time.now
  result_url = uploader.upload!(options[:verbose]) # Do the file upload

  Whirly.status = 'Done!\n'
  Clipboard.copy(result_url)
  print Paint["Your url is: #{result_url} (copied to clipboard) ", :bold]
  puts Paint["[#{((Time.now - beginning_time)).round(2)}s]", '#95a5a6']

  puts Paint['Deployment successful!', '#3498db']
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rise-cli-0.1.8 bin/rise