Sha256: 08a428a7c3727e84b01d20d7e68e91e4720dd76ec4e6305177892886cb7493ec

Contents?: true

Size: 1.26 KB

Versions: 10

Compression:

Stored size: 1.26 KB

Contents

module CLI
  module UI
    module OS
      # Determines which OS is currently running the UI, to make it easier to
      # adapt its behaviour to the features of the OS.
      def self.current
        @current_os ||= case RbConfig::CONFIG['host_os']
        when /darwin/
          Mac
        when /linux/
          Linux
        else
          if RUBY_PLATFORM !~ /cygwin/ && ENV['OS'] == 'Windows_NT'
            Windows
          else
            raise "Could not determine OS from host_os #{RbConfig::CONFIG["host_os"]}"
          end
        end
      end

      class Mac
        class << self
          def supports_emoji?
            true
          end

          def supports_color_prompt?
            true
          end

          def supports_arrow_keys?
            true
          end

          def shift_cursor_on_line_reset?
            false
          end
        end
      end

      class Linux < Mac
      end

      class Windows
        class << self
          def supports_emoji?
            false
          end

          def supports_color_prompt?
            false
          end

          def supports_arrow_keys?
            false
          end

          def shift_cursor_on_line_reset?
            true
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
shopify-cli-2.15.2 vendor/deps/cli-ui/lib/cli/ui/os.rb
shopify-cli-2.15.1 vendor/deps/cli-ui/lib/cli/ui/os.rb
shopify-cli-2.15.0 vendor/deps/cli-ui/lib/cli/ui/os.rb
shopify-cli-2.14.0 vendor/deps/cli-ui/lib/cli/ui/os.rb
shopify-cli-2.13.0 vendor/deps/cli-ui/lib/cli/ui/os.rb
shopify-cli-2.12.0 vendor/deps/cli-ui/lib/cli/ui/os.rb
shopify-cli-2.11.2 vendor/deps/cli-ui/lib/cli/ui/os.rb
shopify-cli-2.11.1 vendor/deps/cli-ui/lib/cli/ui/os.rb
shopify-cli-2.11.0 vendor/deps/cli-ui/lib/cli/ui/os.rb
shopify-cli-2.10.2 vendor/deps/cli-ui/lib/cli/ui/os.rb