59 lines
1.8 KiB
Ruby
Executable File
59 lines
1.8 KiB
Ruby
Executable File
#!/usr/bin/env ruby
|
|
STDOUT.sync = true
|
|
|
|
$:.unshift File.join(File.dirname(__FILE__), *%w{ .. lib })
|
|
|
|
require 'jekyll'
|
|
require 'mercenary'
|
|
|
|
Jekyll::Deprecator.process(ARGV)
|
|
|
|
Mercenary.program(:jekyll) do |p|
|
|
p.version Jekyll::VERSION
|
|
p.description 'Jekyll is a blog-aware, static site generator in Ruby'
|
|
p.syntax 'jekyll <subcommand> [options]'
|
|
|
|
p.option 'source', '-s', '--source [DIR]', 'Source directory (defaults to ./)'
|
|
p.option 'destination', '-d', '--destination [DIR]', 'Destination directory (defaults to ./_site)'
|
|
p.option 'safe', '--safe', 'Safe mode (defaults to false)'
|
|
p.option 'plugins', '-p', '--plugins PLUGINS_DIR1[,PLUGINS_DIR2[,...]]', Array, 'Plugins directory (defaults to ./_plugins)'
|
|
p.option 'layouts', '--layouts DIR', String, 'Layouts directory (defaults to ./_layouts)'
|
|
|
|
Jekyll::Command.subclasses.each { |c| c.init_with_program(p) }
|
|
|
|
p.action do |args, options|
|
|
if args.empty?
|
|
puts p
|
|
else
|
|
unless p.has_command?(args.first)
|
|
Jekyll.logger.abort_with "Invalid command. Use --help for more information"
|
|
end
|
|
end
|
|
end
|
|
|
|
p.command(:import) do |c|
|
|
c.syntax 'import <platform> [options]'
|
|
c.description 'Import your old blog to Jekyll'
|
|
importers = []
|
|
|
|
begin
|
|
require 'jekyll-import'
|
|
importers = JekyllImport.add_importer_commands(c)
|
|
rescue LoadError
|
|
end
|
|
|
|
c.action do |args, options|
|
|
unless Object.const_defined?(:JekyllImport)
|
|
msg = "You must install the 'jekyll-import' gem before continuing.\n"
|
|
msg += "* Please see the documentation at http://jekyllrb.com/docs/migrations/ for instructions.\n"
|
|
abort msg
|
|
end
|
|
if args.empty?
|
|
Jekyll.logger.warn "You must specify an importer."
|
|
Jekyll.logger.info "Valid options are:"
|
|
importers.each { |i| Jekyll.logger.info "*", "#{i}" }
|
|
end
|
|
end
|
|
end
|
|
end
|