Class: Jekyll::Commands::Book

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

Class Method Summary collapse

Class Method Details

.add_options(cmd) ⇒ Object



24
25
26
27
28
# File 'lib/jekyll/commands/book.rb', line 24

def self.add_options(cmd)
  cmd.option "name", "-n", "--name NAME"
  cmd.option "title", "-t", "--title TITLE"
  cmd.option "forced", "-f", "--forced"
end

.init_with_program(prog) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/jekyll/commands/book.rb', line 6

def self.init_with_program(prog)
  prog.command(:book) do |c|
    c.syntax "book [options]"
    c.description 'Create a new book.'
  
    add_options(c)
  
    c.action do |args, options|
      configs = Jekyll.configuration()
      BookWriter.new(
        options["name"],
        File.join(configs["source"], "_books"),
        options
      ).run
    end
  end
end