Sha256: aafc6c9693cd3361c4adcfde09963584207ef81e0e75717bd552260326d147b5

Contents?: true

Size: 1.8 KB

Versions: 1

Compression:

Stored size: 1.8 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.is_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]) unless options[:directory].nil?
uploader = Rise::Transport::Uploader.new(Dir.pwd) if options[:directory].nil?


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.6 bin/rise