networkctl/src/autodetect_environment.cr

26 lines
434 B
Crystal

class Autodetect
def self.uname
os = nil : String?
# do not fake it
Process.run("uname") do |p|
p.output.each_line do |line|
os = line
end
end
os
end
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