Sha256: a046f0a9ab483f84d5b9606dc1cb9aa69035296c694dfdb668bcfda850afcb93

Contents?: true

Size: 1.84 KB

Versions: 17

Compression:

Stored size: 1.84 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
        show_windows_warning if Gem.win_platform?

        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 HomeNotSetError
        raise if debug?
        say_error "Please set HOME environment variable."
      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

17 entries across 17 versions & 1 rubygems

Version Path
shelly-0.5.7 lib/shelly/cli/runner.rb
shelly-0.5.6 lib/shelly/cli/runner.rb
shelly-0.5.5 lib/shelly/cli/runner.rb
shelly-0.5.4 lib/shelly/cli/runner.rb
shelly-0.5.3 lib/shelly/cli/runner.rb
shelly-0.5.2 lib/shelly/cli/runner.rb
shelly-0.5.1 lib/shelly/cli/runner.rb
shelly-0.5.0 lib/shelly/cli/runner.rb
shelly-0.4.42 lib/shelly/cli/runner.rb
shelly-0.4.41 lib/shelly/cli/runner.rb
shelly-0.4.40 lib/shelly/cli/runner.rb
shelly-0.4.39 lib/shelly/cli/runner.rb
shelly-0.4.38 lib/shelly/cli/runner.rb
shelly-0.4.37 lib/shelly/cli/runner.rb
shelly-0.4.36 lib/shelly/cli/runner.rb
shelly-0.4.35 lib/shelly/cli/runner.rb
shelly-0.4.34 lib/shelly/cli/runner.rb