lib/bbiff/executable.rb in bbiff-0.2.1 vs lib/bbiff/executable.rb in bbiff-0.2.2
- old
+ new
@@ -1,10 +1,13 @@
require 'unicode/display_width'
module Bbiff
class Executable
+ class UsageError < StandardError
+ end
+
class LineIndicator
def initialize(out = STDOUT)
@width = 0
@out = out
end
@@ -117,12 +120,11 @@
EOD
end
def main
if ARGV.include?('-h') || ARGV.include?('--help')
- usage
- exit 1
+ raise UsageError
end
if ARGV.size < 1 && !@settings.current['thread_url']
raise UsageError
elsif ARGV.size < 1
@@ -145,9 +147,12 @@
end
thread = Bbs::C板.new(*ita).thread(sure)
start_no = ARGV[1] ? ARGV[1].to_i : thread.last + 1
start_polling(thread, start_no)
+ rescue UsageError
+ usage
+ exit 1
ensure
@settings.save
end
end