def self.main(argv=ARGV,extra_options=[],extra_options_usage=nil,device=nil,exec=File.basename($0))
options = parse_options(argv,*extra_options)
unless options[:mountpoint]
$stderr.puts "rfuse: failed, no mountpoint provided"
puts usage(device,exec)
return nil
end
if options[:help]
puts usage(device,exec)
help_io = STDERR
help_io.puts "Fuse options: (#{FUSE_MAJOR_VERSION}.#{FUSE_MINOR_VERSION})"
help_io.puts " -h help - print this help output"
help_io.puts " -d |-o debug enable internal FUSE debug output"
help_io.puts ""
help_io.flush()
Fuse.new(*argv)
if extra_options_usage
help_io.puts "Filesystem options:"
help_io.puts extra_options_usage
end
return nil
end
begin
fs = yield options,argv
raise Error, "no filesystem provided" unless fs
fuse = create(fs,argv,options,extra_options)
raise Error, "filesystem #{fs} not mounted" unless fuse && fuse.mounted?
fuse.run
rescue Error => fuse_ex
puts usage(device,exec) unless options[:help]
$stderr.puts "rfuse failed: #{fuse_ex.message}"
return nil
rescue => ex
$stderr.puts ex.message
$stderr.puts ex.backtrace.join("\n")
end
end