Class: Jekyll::Commands::MyNewCommand

Inherits:
Jekyll::Command
  • Object
show all
Defined in:
lib/jekyll-url.rb

Class Method Summary collapse

Class Method Details

.init_with_program(prog) ⇒ Object



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/jekyll-url.rb', line 7

def init_with_program(prog)
  prog.command(:url) do |c|
    c.syntax "new [options]"
    c.description 'Create a new Jekyll site.'

    c.option 'dest', '-d DEST', 'Where the site should go.'

    add_build_options(c)

    c.action do |args, options|
      file_name = args[0]
      options = configuration_from_options(options)
      site = Jekyll::Site.new(options)
      site.reset
      site.read
      all_pages = site.pages + site.posts
      found_page = all_pages.find do |page|
        page.relative_path == file_name
      end
      puts found_page.url
    end
  end
end