Class: Octopress::Publish
- Defined in:
- lib/octopress/commands/publish.rb
Class Method Summary collapse
Methods inherited from Command
inherited, #init_with_program, subclasses
Class Method Details
.init_with_program(p) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/octopress/commands/publish.rb', line 3 def self.init_with_program(p) p.command(:publish) do |c| c.syntax 'publish <DRAFT> [options]' c.description 'Convert a draft to a normal published post.' c.option 'date', '--date DATE', 'String that is parseable by Time#parse. (default: Time.now.iso8601)' c.option 'force', '--force', 'Overwrite file if it already exists' c.option 'dir', '--dir DIR', 'Create post at _posts/DIR/.' CommandHelpers. c c.action do |args, | abort "You didn't specify a post." if args.empty? ['path'] = args.first ['type'] = 'post from draft' if !['path'] abort "Publish failed: Please provide a path or a search string to select your post." end if File.exist?(['path']) publish_post() else ['path'] = CommandHelpers.select_posts(['path'], 'publish') publish_post() end end end end |