From bfa525518841521336c57d1391779a62e1bbd68a Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Mon, 21 May 2012 08:57:49 -0500 Subject: [PATCH] Rake new post now accepts: - Inline input as in `rake new_post["Your post title"] - Input from stdin if in-line input isn't given. This should help zhs users who've been frustrated by globbing issues. Fixes #117 --- Rakefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index 8675877..bb5555f 100644 --- a/Rakefile +++ b/Rakefile @@ -91,10 +91,13 @@ end # usage rake new_post[my-new-post] or rake new_post['my new post'] or rake new_post (defaults to "new-post") desc "Begin a new post in #{source_dir}/#{posts_dir}" task :new_post, :title do |t, args| + if args.title + title = args.title + else + title = get_stdin("Enter a title for your post: ") + end raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir) mkdir_p "#{source_dir}/#{posts_dir}" - args.with_defaults(:title => 'new-post') - title = args.title filename = "#{source_dir}/#{posts_dir}/#{Time.now.strftime('%Y-%m-%d')}-#{title.to_url}.#{new_post_ext}" if File.exist?(filename) abort("rake aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'