lib/fusuma.rb in fusuma-0.1.6 vs lib/fusuma.rb in fusuma-0.1.7
- old
+ new
@@ -12,15 +12,34 @@
# this is top level module
module Fusuma
# main class
class Runner
- def self.run(args = {})
- debug = args.fetch(:v, false)
- MultiLogger.instance.debug_mode = true if debug
- instance = new
- MultiLogger.debug('Enable debug lines')
- instance.read_libinput
+ class << self
+ def run(args = {})
+ read_options(args)
+ return if @stop
+ instance = new
+ instance.read_libinput
+ end
+
+ def read_options(args)
+ debug = args.fetch(:v, false)
+ help = args.fetch(:h, false)
+ MultiLogger.instance.debug_mode = true if debug
+ @stop = if help
+ print_help
+ true
+ else
+ false
+ end
+ end
+
+ def print_help
+ puts 'Options:
+ -h, print this help.
+ -v, print to STDOUT with debug mode.'
+ end
end
def read_libinput
Open3.popen3(libinput_command) do |_i, o, _e, _w|
o.each do |line|