From 702e538e964e7cb07a4b95029da1ebebec0f1a61 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Sat, 6 Dec 2008 15:05:39 -0800 Subject: [PATCH] refactor processing calls --- bin/jekyll | 49 +++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/bin/jekyll b/bin/jekyll index e70e1058..a1d09d19 100755 --- a/bin/jekyll +++ b/bin/jekyll @@ -6,16 +6,7 @@ require 'optparse' require 'jekyll' opts = OptionParser.new do |opts| - opts.banner = <<-EOF -Jekyll is a blog-aware, static site generator. - -Basic Command Line Usage: - jekyll # . -> ./_site - jekyll # . -> - jekyll # -> - - Options: -EOF + opts.banner = DATA.read opts.on("--auto", "Auto-regenerate") do options[:auto] = true @@ -24,16 +15,38 @@ end opts.parse! +def process_local_to_local + dest = File.join('.', '_site') + FileUtils.rm_rf(dest) + FileUtils.mkdir_p(dest) + Jekyll.process('.', dest) +end + +def process_local_to_path + Jekyll.process('.', ARGV[0]) +end + +def process_path_to_path + Jekyll.process(ARGV[0], ARGV[1]) +end + case ARGV.size when 0 - dest = File.join('.', '_site') - FileUtils.rm_rf(dest) - FileUtils.mkdir_p(dest) - Jekyll.process('.', dest) + process_local_to_local when 1 - Jekyll.process('.', ARGV[0]) + process_local_to_path when 2 - Jekyll.process(ARGV[0], ARGV[1]) + process_path_to_path else - puts DATA.read -end \ No newline at end of file + puts "Invalid options. Run `jekyll --help` for assistance." +end + +__END__ +Jekyll is a blog-aware, static site generator. + +Basic Command Line Usage: + jekyll # . -> ./_site + jekyll # . -> + jekyll # -> + + Options: \ No newline at end of file