lib/bolt.rb in benofsky-bolt-0.3.3 vs lib/bolt.rb in benofsky-bolt-0.4

- old
+ new

@@ -12,11 +12,12 @@ module Bolt class Bolt def initialize $config = OpenStruct.new @commands = {"create" => true, - "build" => true} + "build" => true, + "serve" => true} end # Parses command line options then runs the specified command def run parse_options @@ -40,22 +41,29 @@ # a bolt project and saving all files into the "out" directory. def build require 'bolt/build' Build.new.run end + + def serve + require 'bolt/serve' + Serve.new.run + end # Parses command line options def parse_options $config.resources = "resources" $config.lib = "lib" $config.views = "views" $config.out = "out" $config.pages = "pages" $config.config = "config.yml" + $config.serve_host = "127.0.0.1" + $config.serve_port = "2658" opts = OptionParser.new do |opts| - opts.banner = "Usage: bolt {create/build} [options] [file]" + opts.banner = "Usage: bolt {create/build/serve} [options] [file]" opts.on("-r", "--resources [resource-dir]", "Resources directory") do |opts| $config.resources = opts end @@ -75,9 +83,17 @@ $config.out = opts end opts.on("-c", "--config [config-file.yml]", "Config file") do |opts| $config.config = opts + end + + opts.on("-H", "--host [host]", "Serve development server host") do |opts| + $config.serve_host = opts + end + + opts.on("-P", "--port [port]", "Serve development server port") do |opts| + $config.serve_port = opts end opts.on_tail("-h", "--help", "Show this help message") do puts opts exit