#!/usr/bin/env ruby require "mado" require "optparse" require "pathname" options = {} parser = OptionParser.new("Usage: mado [options] FILE") do |opt| opt.on("-p", "--port=VAL", "Port number (default: 8080)") { |val| options[:port] = val.to_i } opt.on("-a", "--addr=VAL", "Address to bind (default: 0.0.0.0)") { |val| options[:host] = val } opt.on("--debug", "Debug mode") { |val| options[:debug] = val } end argv = parser.parse(ARGV) if argv.length < 1 puts parser.help exit 1 end path = argv.shift begin options[:markdown] = Pathname.new(path).realpath.to_s rescue $stderr.puts "mado: File not found - #{path}" exit 1 end Mado::Server.run(options)