Raxol.System.Platform (Raxol v0.3.0)

View Source

Platform-specific functionality and detection for Raxol.

This module handles detection of the current platform, providing platform-specific information, and managing platform-dependent operations.

Summary

Functions

Returns the current platform as an atom.

Returns the executable name for the current platform.

Returns the file extension for the current platform.

Gathers detailed information about the current platform.

Returns the platform name as a string.

Detects if the feature is supported on the current platform.

Functions

get_current_platform()

@spec get_current_platform() :: :linux | :macos | :windows

Returns the current platform as an atom.

Returns

  • :macos - macOS (Darwin)
  • :linux - Linux variants
  • :windows - Windows

Examples

iex> Platform.get_current_platform()
:macos

get_executable_name()

@spec get_executable_name() :: String.t()

Returns the executable name for the current platform.

Returns

  • "raxol.exe" - Windows platforms
  • "raxol" - Unix platforms (macOS, Linux)

Examples

iex> Platform.get_executable_name()
"raxol"

get_platform_extension()

@spec get_platform_extension() :: String.t()

Returns the file extension for the current platform.

Returns

  • "zip" - Windows platforms
  • "tar.gz" - Unix platforms (macOS, Linux)

Examples

iex> Platform.get_platform_extension()
"tar.gz"

get_platform_info()

@spec get_platform_info() :: %{
  :name => :linux | :macos | :windows,
  :version => String.t() | nil,
  :architecture => String.t(),
  :terminal => String.t(),
  optional(:console_type) => String.t(),
  optional(:distribution) => String.t(),
  optional(:is_apple_silicon) => boolean(),
  optional(:is_wayland) => boolean(),
  optional(:is_windows_terminal) => boolean(),
  optional(:is_wsl) => boolean(),
  optional(:terminal_app) => String.t()
}

Gathers detailed information about the current platform.

Returns

A map containing platform details including:

  • :name - Platform name (e.g., "macOS", "Linux", "Windows")
  • :version - OS version if available
  • :architecture - CPU architecture (e.g., "x86_64", "arm64")
  • :terminal - Current terminal information if available

Examples

iex> Platform.get_platform_info()
%{
  name: "macOS",
  version: "12.6",
  architecture: "arm64",
  terminal: "iTerm.app"
}

get_platform_name()

@spec get_platform_name() :: String.t()

Returns the platform name as a string.

Returns

  • "macos" - macOS (Darwin)
  • "linux" - Linux variants
  • "windows" - Windows

Examples

iex> Platform.get_platform_name()
"macos"

supports_feature?(feature)

@spec supports_feature?(atom()) :: boolean()

Detects if the feature is supported on the current platform.

Parameters

  • feature - Feature name as an atom (e.g., :true_color, :unicode, :mouse)

Returns

  • true - Feature is supported on the current platform
  • false - Feature is not supported or support is uncertain

Examples

iex> Platform.supports_feature?(:true_color)
true