aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon Mathis <brandon@imathis.com>2013-01-01 14:22:48 -0600
committerBrandon Mathis <brandon@imathis.com>2013-01-01 14:22:48 -0600
commit65f7f7f0b3fa2264336d21a169b7ef426079dd2d (patch)
treefb75bd43c7ebe87cb26b91ba5c3d756311a126fd
parent67d07b9dcec75562652e7391ddb2b5f7cf2e36e2 (diff)
downloadmy_new_personal_website-65f7f7f0b3fa2264336d21a169b7ef426079dd2d.tar.xz
my_new_personal_website-65f7f7f0b3fa2264336d21a169b7ef426079dd2d.zip
Rake task new_post now accepts titles through stdin
This should help resolve issues for zsh users and make it easier to enter titles which freak out Rake's argument processing
-rw-r--r--Rakefile7
1 files changed, 5 insertions, 2 deletions
diff --git a/Rakefile b/Rakefile
index ef9af471..6c699df3 100644
--- a/Rakefile
+++ b/Rakefile
@@ -92,10 +92,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'