Sha256: 709522a19d7f6c30f8921b649f92b16a02ead548f665c69d1ec4d79b5d4d3d3e

Contents?: true

Size: 1.68 KB

Versions: 16

Compression:

Stored size: 1.68 KB

Contents

require "shelly/cli/main"

module Shelly
  module CLI
    class Runner < Thor::Shell::Basic
      include Helpers
      attr_accessor :args

      def initialize(args = [])
        super()
        @args = args
      end

      def debug?
        args.include?("--debug") || ENV['SHELLY_DEBUG'] == "true"
      end

      def start
        Shelly::CLI::Main.start(args)
      rescue SystemExit; raise
      rescue Client::UnauthorizedException
        raise if debug?
        say_error "You are not logged in. To log in use: `shelly login`"
      rescue Client::NotFoundException => e
        raise if debug? or e.resource != :cloud
        say_error "You have no access to '#{e.id}' cloud"
      rescue Client::GemVersionException => e
        raise if debug?
        say "Required shelly gem version: #{e.body["required_version"]}"
        say "Your version: #{VERSION}"
        if yes? "Update shelly gem?"
          system "gem install shelly"
        else
          say_error "Update shelly gem with `gem install shelly`"
        end
      rescue Interrupt
        raise if debug?
        say_new_line
        say_error "[canceled]"
      rescue Netrc::Error => e
        raise if debug?
        say_error e.message
      rescue Client::APIException => e
        raise if debug?
        say_error "You have found a bug in the shelly gem. We're sorry.",
          :with_exit => e.request_id.blank?
        say_error <<-eos
You can report it to support@shellycloud.com by describing what you wanted
to do and mentioning error id #{e.request_id}.
        eos
      rescue Exception
        raise if debug?
        say_error "Unknown error, to see debug information run command with --debug"
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
shelly-0.4.32 lib/shelly/cli/runner.rb
shelly-0.4.31 lib/shelly/cli/runner.rb
shelly-0.4.30 lib/shelly/cli/runner.rb
shelly-0.4.29 lib/shelly/cli/runner.rb
shelly-0.4.29.pre lib/shelly/cli/runner.rb
shelly-0.4.28 lib/shelly/cli/runner.rb
shelly-0.4.28.pre2 lib/shelly/cli/runner.rb
shelly-0.4.28.pre lib/shelly/cli/runner.rb
shelly-0.4.27 lib/shelly/cli/runner.rb
shelly-0.4.26 lib/shelly/cli/runner.rb
shelly-0.4.26.pre lib/shelly/cli/runner.rb
shelly-0.4.25 lib/shelly/cli/runner.rb
shelly-0.4.24 lib/shelly/cli/runner.rb
shelly-0.4.23 lib/shelly/cli/runner.rb
shelly-0.4.23.pre lib/shelly/cli/runner.rb
shelly-0.4.22 lib/shelly/cli/runner.rb