From 3aff974d68ddf646220ccdb6cf7d18142167efe9 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Fri, 20 Jul 2012 15:28:03 -0400 Subject: [PATCH] option to run on different ports --- bin/sharkfrown | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bin/sharkfrown b/bin/sharkfrown index f53e436..9fe8eb7 100755 --- a/bin/sharkfrown +++ b/bin/sharkfrown @@ -5,6 +5,16 @@ require 'rack' require 'pygmentize' require 'redcarpet' +require 'optparse' + +options = { :port => 6789, :verbose => false } +OptionParser.new do |opts| + opts.banner = "Usage: sharkfrown [options]" + + opts.on('-p', '--port PORT', "Change port (default: #{options[:port]}") { |v| options[:port] = v.to_i } + opts.on('-v', '--verbose', "Verbose (show request log)") { |v| options[:verbose] = true } +end.parse! + class Sharkfrown class PygmentizeHTML < Redcarpet::Render::HTML def block_code(code, language) @@ -72,8 +82,8 @@ HTML end end -Thin::Server.start('0.0.0.0', 6789) do - use Rack::CommonLogger +Thin::Server.start('0.0.0.0', options[:port]) do + use Rack::CommonLogger if options[:verbose] use Rack::ShowExceptions run Sharkfrown.new