Class: Jekyll::Commands::Unpublish

Inherits:
Command
  • Object
show all
Defined in:
lib/jekyll/commands/unpublish.rb

Class Method Summary collapse

Class Method Details

.init_with_program(prog) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/jekyll/commands/unpublish.rb', line 6

def self.init_with_program(prog)
  prog.command(:unpublish) do |c|
    c.syntax "unpublish POST_PATH"
    c.description "Moves a post back into the _drafts directory"

    options.each { |opt| c.option(*opt) }

    c.action { |args, options| process(args, options) }
  end
end

.optionsObject



17
18
19
20
21
22
# File 'lib/jekyll/commands/unpublish.rb', line 17

def self.options
  [
    ["config", "--config CONFIG_FILE[,CONFIG_FILE2,...]", Array, "Custom configuration file"],
    ["force", "-f", "--force", "Overwrite a draft if it already exists"],
  ]
end

.process(args = [], options = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/jekyll/commands/unpublish.rb', line 24

def self.process(args = [], options = {})
  config = configuration_from_options(options)
  params = UnpublishArgParser.new(args, options, config)
  params.validate!

  movement = PostMovementInfo.new(params)

  mover = PostMover.new(movement, params.force?, params.source)
  mover.move
end