| 
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 | # File 'lib/view_server/show_runner.rb', line 5
def self.parse(args)
  options = {:port => 10021}
  opt_parser = OptionParser.new do |opts|
    opts.banner = "Usage: show [options] [file]"
    opts.on("-e", "--extension EXTENSION", "File extension") do |v|
      options[:ext] = v
    end
    opts.on("-p", "--port PORT", "Port number. Default is 10021") do |v|
      options[:port] = Integer(v)
    end
  end
  opt_parser.parse!(args)
  filename = ARGV.first
  if filename
    data = File.read filename
    ext = File.extname(filename)[1..-1]
  else
    data = $stdin.read
    ext = options.fetch(:ext) {'txt'}
  end
  options.merge({:data => data, :ext => ext })
end |