Sha256: 9ce582cea4800a1b75594ef6ed8e3b7d42136db318d167cbf6544fe2efa0a8b9

Contents?: true

Size: 1.18 KB

Versions: 27

Compression:

Stored size: 1.18 KB

Contents

module Octopress
  class Publish < Command
    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.add_common_options c

        c.action do |args, options|
          abort "You didn't specify a post." if args.empty?
          options['path'] = args.first
          options['type'] = 'post from draft'

          if !options['path']
            abort "Publish failed: Please provide a path or a search string to select your post."
          end

          if File.exist?(options['path'])
            publish_post(options)
          else
            options['path'] = CommandHelpers.select_posts(options['path'], 'publish')
            publish_post(options)
          end
        end
      end
    end

    def self.publish_post(options)
      Draft.new(Octopress.site(options), options).publish
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
octopress-3.0.12.pre.1 lib/octopress/commands/publish.rb
octopress-3.0.11 lib/octopress/commands/publish.rb
octopress-3.0.10 lib/octopress/commands/publish.rb
octopress-3.0.9 lib/octopress/commands/publish.rb
octopress-3.0.8 lib/octopress/commands/publish.rb
octopress-3.0.7 lib/octopress/commands/publish.rb
octopress-3.0.6 lib/octopress/commands/publish.rb
octopress-3.0.5 lib/octopress/commands/publish.rb
octopress-3.0.4 lib/octopress/commands/publish.rb
octopress-3.0.3.alpha.2 lib/octopress/commands/publish.rb
octopress-3.0.3.alpha.1 lib/octopress/commands/publish.rb
octopress-3.0.3.alpha.0 lib/octopress/commands/publish.rb
octopress-3.0.2 lib/octopress/commands/publish.rb
octopress-3.0.1 lib/octopress/commands/publish.rb
octopress-3.0.0 lib/octopress/commands/publish.rb
octopress-3.0.0.rc.37 lib/octopress/commands/publish.rb
octopress-3.0.0.rc.36 lib/octopress/commands/publish.rb
octopress-3.0.0.rc.35 lib/octopress/commands/publish.rb
octopress-3.0.0.rc.34 lib/octopress/commands/publish.rb
octopress-3.0.0.rc.33 lib/octopress/commands/publish.rb