Sha256: a66c9256b7a4f7a3df723f2fa32a7a7aee2d75ae42f84f28781deee73572eb8c
Contents?: true
Size: 1.1 KB
Versions: 1
Compression:
Stored size: 1.1 KB
Contents
#!/usr/bin/env ruby require 'rubygems' require 'applix' $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') require 'usb-detection-sensor' class Usage < ArgumentError; end # TODO: refactoring this into gom-core logger def redirect_log path unless path == '-' # '-' means stdout means nothing puts " -- redirecting stdout/stderr to: #{path}" out = File.open(path, File::WRONLY|File::APPEND|File::CREAT) out.sync = true $stderr = $stdout = out # first line after redirect puts " -- logile redirect at #{Time.now}" end end def main argv options = Hash.from_argv argv args = (options.delete :args) handler = UsbDetectionSensor::CommandLineHandler.new options redirect_log handler.logfile if op = args.shift handler.send op, *args else # TODO: process could become part of the udev rule script and this special # case would went extinct handler.process ENV end rescue Usage => e puts <<-TXT usage: #{__FILE__} [ <connect> | <disconnect> ] ## #{e} TXT rescue => e puts " ## #{e}\n -> #{e.backtrace.join "\n "}" end main ARGV # vim: syntax=ruby
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
usb-detection-sensor-0.2.2 | bin/usb-udev-rules-handler |