Sha256: 73452484da76021cd74c6f17f2cee2196cae0579902171ff4183431f2c245ed4

Contents?: true

Size: 1022 Bytes

Versions: 3

Compression:

Stored size: 1022 Bytes

Contents

module Octopress
  class Unpublish < Command
    def self.init_with_program(p)
      p.command(:unpublish) do |c|
        c.syntax 'unpublish <POST> [options]'
        c.option 'force', '--force', 'Overwrite draft if it already exists'
        c.description 'Convert a post to a draft. Command accepts path to post or search string.'
        CommandHelpers.add_common_options c

        c.action do |args, options|
          options['path'] = args.first
          options['type'] = 'draft from post'

          if !options['path']
            abort "Unpublish failed: Please provide a path or a search string to select your post."
          end
          if File.exist?(options['path'])
            unpublish_post(options)
          else
            options['path'] = CommandHelpers.select_posts(options['path'], 'unpublish')
            unpublish_post(options)
          end
        end
      end
    end

    def self.unpublish_post(options)
      Post.new(Octopress.site(options), options).unpublish
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
octopress-3.0.12.pre.1 lib/octopress/commands/unpublish.rb
octopress-3.0.11 lib/octopress/commands/unpublish.rb
octopress-3.0.10 lib/octopress/commands/unpublish.rb