Module: AiCli::Helpers::OsDetect

Defined in:
lib/aicli/helpers/os_detect.rb

Class Method Summary collapse

Class Method Details

.detect_shellObject



11
12
13
14
15
16
17
18
# File 'lib/aicli/helpers/os_detect.rb', line 11

def detect_shell
  return 'powershell' if RUBY_PLATFORM.match?(/mswin|mingw|cygwin/i)

  shell = ENV['SHELL'] || Etc.getpwuid.shell || 'bash'
  File.basename(shell)
rescue StandardError => e
  raise "#{I18n.t('Shell detection failed unexpectedly')}: #{e.message}"
end

.operating_system_nameObject



20
21
22
23
24
25
26
27
28
# File 'lib/aicli/helpers/os_detect.rb', line 20

def operating_system_name
  case RbConfig::CONFIG['host_os']
  when /mswin|mingw|cygwin/i then 'Windows'
  when /darwin/i then 'macOS'
  when /linux/i then 'Linux'
  when /bsd/i then 'BSD'
  else RbConfig::CONFIG['host_os']
  end
end