2019-10-14 00:42:15 +02:00
|
|
|
|
|
|
|
class Autodetect
|
2019-10-30 16:02:57 +01:00
|
|
|
def self.uname
|
|
|
|
os = nil : String?
|
2019-11-08 01:20:38 +01:00
|
|
|
# do not fake it
|
|
|
|
Process.run("uname") do |p|
|
2019-10-30 16:02:57 +01:00
|
|
|
p.output.each_line do |line|
|
|
|
|
os = line
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
os
|
|
|
|
end
|
2019-10-14 00:42:15 +02:00
|
|
|
class_property print_autodetect : Bool = false
|
|
|
|
|
|
|
|
def self.which(cmd : String)
|
|
|
|
if Process.run("which", [ cmd ]).success?
|
|
|
|
puts "#{cmd} installed" if print_autodetect
|
|
|
|
true
|
|
|
|
else
|
|
|
|
puts "#{cmd} not installed" if print_autodetect
|
|
|
|
false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|