refactor processing calls

This commit is contained in:
Tom Preston-Werner 2008-12-06 15:05:39 -08:00
parent 3f8b9a08fa
commit 702e538e96
1 changed files with 31 additions and 18 deletions

View File

@ -6,16 +6,7 @@ require 'optparse'
require 'jekyll' require 'jekyll'
opts = OptionParser.new do |opts| opts = OptionParser.new do |opts|
opts.banner = <<-EOF opts.banner = DATA.read
Jekyll is a blog-aware, static site generator.
Basic Command Line Usage:
jekyll # . -> ./_site
jekyll <path to write generated site> # . -> <path>
jekyll <path to source> <path to write generated site> # <path> -> <path>
Options:
EOF
opts.on("--auto", "Auto-regenerate") do opts.on("--auto", "Auto-regenerate") do
options[:auto] = true options[:auto] = true
@ -24,16 +15,38 @@ end
opts.parse! opts.parse!
case ARGV.size def process_local_to_local
when 0
dest = File.join('.', '_site') dest = File.join('.', '_site')
FileUtils.rm_rf(dest) FileUtils.rm_rf(dest)
FileUtils.mkdir_p(dest) FileUtils.mkdir_p(dest)
Jekyll.process('.', dest) Jekyll.process('.', dest)
when 1
Jekyll.process('.', ARGV[0])
when 2
Jekyll.process(ARGV[0], ARGV[1])
else
puts DATA.read
end 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
process_local_to_local
when 1
process_local_to_path
when 2
process_path_to_path
else
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 <path to write generated site> # . -> <path>
jekyll <path to source> <path to write generated site> # <path> -> <path>
Options: