Skip to content

Latest commit

 

History

History
64 lines (55 loc) · 1.63 KB

commands.md

File metadata and controls

64 lines (55 loc) · 1.63 KB
title
Commands

Commands

As of version 2.5.0, Jekyll can be extended with plugins which provide subcommands for the jekyll executable. This is possible by including the relevant plugins in a Gemfile group called :jekyll_plugins:

{% highlight ruby %} group :jekyll_plugins do gem "my_fancy_jekyll_plugin" end {% endhighlight %}

Each Command must be a subclass of the Jekyll::Command class and must contain one class method: init_with_program. An example:

{% highlight ruby %} class MyNewCommand < Jekyll::Command class << self def init_with_program(prog) prog.command(:new) do |c| c.syntax "new [options]" c.description 'Create a new Jekyll site.'

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

    c.action do |args, options|
      Jekyll::Site.new_site_at(options['dest'])
    end
  end
end

end end {% endhighlight %}

Commands should implement this single class method:

Method Description

init_with_program

This method accepts one parameter, the Mercenary::Program instance, which is the Jekyll program itself. Upon the program, commands may be created using the above syntax. For more details, visit the Mercenary repository on GitHub.com.