From 5cf6f2c2d16fabcdd2cba24dde06a52c40ba3a43 Mon Sep 17 00:00:00 2001 From: "maul.esel" Date: Thu, 17 Oct 2013 11:32:26 +0200 Subject: [PATCH] move cmd param setup for build into own method to avoid duplication --- bin/jekyll | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/bin/jekyll b/bin/jekyll index ee497c25..d1aee02a 100755 --- a/bin/jekyll +++ b/bin/jekyll @@ -33,6 +33,16 @@ def normalize_options(options) options end +def add_build_options(c) + c.option '--config CONFIG_FILE[,CONFIG_FILE2,...]', Array, 'Custom configuration file' + c.option '--future', 'Publishes posts with a future date' + c.option '--limit_posts MAX_POSTS', Integer, 'Limits the number of posts to parse and publish' + c.option '-w', '--watch', 'Watch for changes and rebuild' + c.option '--lsi', 'Use LSI for improved related posts' + c.option '-D', '--drafts', 'Render posts in the _drafts folder' + c.option '-v', '--verbose', 'Print verbose output.' +end + command :default do |c| c.action do |args, options| if args.empty? @@ -59,13 +69,7 @@ command :build do |c| c.syntax = 'jekyll build [options]' c.description = 'Build your site' - c.option '--config CONFIG_FILE[,CONFIG_FILE2,...]', Array, 'Custom configuration file' - c.option '--future', 'Publishes posts with a future date' - c.option '--limit_posts MAX_POSTS', Integer, 'Limits the number of posts to parse and publish' - c.option '-w', '--watch', 'Watch for changes and rebuild' - c.option '--lsi', 'Use LSI for improved related posts' - c.option '-D', '--drafts', 'Render posts in the _drafts folder' - c.option '-v', '--verbose', 'Print verbose output.' + add_build_options(c) c.action do |args, options| options = normalize_options(options.__hash__) @@ -78,15 +82,9 @@ command :serve do |c| c.syntax = 'jekyll serve [options]' c.description = 'Serve your site locally' - c.option '--config CONFIG_FILE[,CONFIG_FILE2,...]', Array, 'Custom configuration file' - c.option '--future', 'Publishes posts with a future date' - c.option '--limit_posts MAX_POSTS', Integer, 'Limits the number of posts to parse and publish' - c.option '-w', '--watch', 'Watch for changes and rebuild' - c.option '--lsi', 'Use LSI for improved related posts' - c.option '-B', '--detach', 'Run the server in the background (detach)' - c.option '-D', '--drafts', 'Render posts in the _drafts folder' - c.option '-v', '--verbose', 'Print verbose output.' + add_build_options(c) + c.option '-B', '--detach', 'Run the server in the background (detach)' c.option '-P', '--port [PORT]', 'Port to listen on' c.option '-H', '--host [HOST]', 'Host to bind to' c.option '-b', '--baseurl [URL]', 'Base URL'