Sha256: 1f9d3998cdfa4851e79a1b16c9e891f3a38f6c34cb259618fa182ea3202aed43

Contents?: true

Size: 1.37 KB

Versions: 30

Compression:

Stored size: 1.37 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

          def path_separator
            ":"
          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

          def path_separator
            ";"
          end
        end
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
shopify-cli-2.36.0 vendor/deps/cli-ui/lib/cli/ui/os.rb
shopify-cli-2.35.0 vendor/deps/cli-ui/lib/cli/ui/os.rb
shopify-cli-2.34.0 vendor/deps/cli-ui/lib/cli/ui/os.rb
shopify-cli-2.33.1 vendor/deps/cli-ui/lib/cli/ui/os.rb
shopify-cli-2.33.0 vendor/deps/cli-ui/lib/cli/ui/os.rb
shopify-cli-2.32.1 vendor/deps/cli-ui/lib/cli/ui/os.rb
shopify-cli-2.32.0 vendor/deps/cli-ui/lib/cli/ui/os.rb
shopify-cli-2.31.0 vendor/deps/cli-ui/lib/cli/ui/os.rb
shopify-cli-2.30.0 vendor/deps/cli-ui/lib/cli/ui/os.rb
shopify-cli-2.29.0 vendor/deps/cli-ui/lib/cli/ui/os.rb
shopify-cli-2.28.0 vendor/deps/cli-ui/lib/cli/ui/os.rb
shopify-cli-2.27.0 vendor/deps/cli-ui/lib/cli/ui/os.rb
shopify-cli-2.26.0 vendor/deps/cli-ui/lib/cli/ui/os.rb
shopify-cli-2.25.0 vendor/deps/cli-ui/lib/cli/ui/os.rb
shopify-cli-2.24.0 vendor/deps/cli-ui/lib/cli/ui/os.rb
shopify-cli-2.23.0 vendor/deps/cli-ui/lib/cli/ui/os.rb
shopify-cli-2.22.0 vendor/deps/cli-ui/lib/cli/ui/os.rb
shopify-cli-2.21.0 vendor/deps/cli-ui/lib/cli/ui/os.rb
shopify-cli-2.20.1 vendor/deps/cli-ui/lib/cli/ui/os.rb
shopify-cli-2.20.0 vendor/deps/cli-ui/lib/cli/ui/os.rb