Browse code

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

Brandon Mathis authored on 01/01/2013 at 20:22:48
Showing 1 changed files
... ...
@@ -92,10 +92,13 @@ end
92 92
 # usage rake new_post[my-new-post] or rake new_post['my new post'] or rake new_post (defaults to "new-post")
93 93
 desc "Begin a new post in #{source_dir}/#{posts_dir}"
94 94
 task :new_post, :title do |t, args|
95
+  if args.title
96
+    title = args.title
97
+  else
98
+    title = get_stdin("Enter a title for your post: ")
99
+  end
95 100
   raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
96 101
   mkdir_p "#{source_dir}/#{posts_dir}"
97
-  args.with_defaults(:title => 'new-post')
98
-  title = args.title
99 102
   filename = "#{source_dir}/#{posts_dir}/#{Time.now.strftime('%Y-%m-%d')}-#{title.to_url}.#{new_post_ext}"
100 103
   if File.exist?(filename)
101 104
     abort("rake aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'