Merge remote-tracking branch 'MattHall/cli' into test
This commit is contained in:
commit
68eaadd13a
|
@ -1,4 +1,6 @@
|
||||||
== HEAD
|
== HEAD
|
||||||
|
* Major Enhancements
|
||||||
|
* Add command line importer functionality (#253)
|
||||||
* Minor Enhancements
|
* Minor Enhancements
|
||||||
* Switch to Albino gem
|
* Switch to Albino gem
|
||||||
* Bundler support
|
* Bundler support
|
||||||
|
|
82
bin/jekyll
82
bin/jekyll
|
@ -9,7 +9,8 @@ Basic Command Line Usage:
|
||||||
jekyll # . -> ./_site
|
jekyll # . -> ./_site
|
||||||
jekyll <path to write generated site> # . -> <path>
|
jekyll <path to write generated site> # . -> <path>
|
||||||
jekyll <path to source> <path to write generated site> # <path> -> <path>
|
jekyll <path to source> <path to write generated site> # <path> -> <path>
|
||||||
|
jekyll import <importer name> <options> # imports posts using named import script
|
||||||
|
|
||||||
Configuration is read from '<source>/_config.yml' but can be overriden
|
Configuration is read from '<source>/_config.yml' but can be overriden
|
||||||
using the following options:
|
using the following options:
|
||||||
|
|
||||||
|
@ -18,11 +19,37 @@ HELP
|
||||||
require 'optparse'
|
require 'optparse'
|
||||||
require 'jekyll'
|
require 'jekyll'
|
||||||
|
|
||||||
|
|
||||||
exec = {}
|
exec = {}
|
||||||
options = {}
|
options = {}
|
||||||
opts = OptionParser.new do |opts|
|
opts = OptionParser.new do |opts|
|
||||||
opts.banner = help
|
opts.banner = help
|
||||||
|
|
||||||
|
opts.on("--file [PATH]", "File to import from") do |import_file|
|
||||||
|
options['file'] = import_file
|
||||||
|
end
|
||||||
|
|
||||||
|
opts.on("--dbname [TEXT]", "DB to import from") do |import_dbname|
|
||||||
|
options['dbname'] = import_dbname
|
||||||
|
end
|
||||||
|
|
||||||
|
opts.on("--user [TEXT]", "Username to use when importing") do |import_user|
|
||||||
|
options['user'] = import_user
|
||||||
|
end
|
||||||
|
|
||||||
|
opts.on("--pass [TEXT]", "Password to use when importing") do |import_pass|
|
||||||
|
options['pass'] = import_pass
|
||||||
|
end
|
||||||
|
|
||||||
|
opts.on("--host [HOST ADDRESS]", "Host to import from") do |import_host|
|
||||||
|
options['host'] = import_host
|
||||||
|
end
|
||||||
|
|
||||||
|
opts.on("--site [SITE NAME]", "Site to import from") do |import_site|
|
||||||
|
options['site'] = import_site
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
opts.on("--[no-]safe", "Safe mode (default unsafe)") do |safe|
|
opts.on("--[no-]safe", "Safe mode (default unsafe)") do |safe|
|
||||||
options['safe'] = safe
|
options['safe'] = safe
|
||||||
end
|
end
|
||||||
|
@ -105,6 +132,59 @@ end
|
||||||
# Read command line options into `options` hash
|
# Read command line options into `options` hash
|
||||||
opts.parse!
|
opts.parse!
|
||||||
|
|
||||||
|
|
||||||
|
# Check for import stuff
|
||||||
|
if ARGV.size > 0
|
||||||
|
if ARGV[0] == 'import'
|
||||||
|
migrator = ARGV[1]
|
||||||
|
|
||||||
|
if migrator.nil?
|
||||||
|
puts "Invalid options. Run `jekyll --help` for assistance."
|
||||||
|
exit(1)
|
||||||
|
else
|
||||||
|
migrator = migrator.downcase
|
||||||
|
end
|
||||||
|
|
||||||
|
cmd_options = []
|
||||||
|
['file', 'dbname', 'user', 'pass', 'host', 'site'].each do |p|
|
||||||
|
cmd_options << "\"#{options[p]}\"" unless options[p].nil?
|
||||||
|
end
|
||||||
|
|
||||||
|
# It's import time
|
||||||
|
puts "Importing..."
|
||||||
|
|
||||||
|
# Ideally, this shouldn't be necessary. Maybe parse the actual
|
||||||
|
# src files for the migrator name?
|
||||||
|
migrators = {
|
||||||
|
:posterous => 'Posterous',
|
||||||
|
:wordpressdotcom => 'WordpressDotCom',
|
||||||
|
:wordpress => 'Wordpress',
|
||||||
|
:csv => 'CSV',
|
||||||
|
:drupal => 'Drupal',
|
||||||
|
:mephisto => 'Mephisto',
|
||||||
|
:mt => 'MT',
|
||||||
|
:textpattern => 'TextPattern',
|
||||||
|
:typo => 'Typo'
|
||||||
|
}
|
||||||
|
|
||||||
|
app_root = File.join(File.dirname(__FILE__), '..')
|
||||||
|
|
||||||
|
require "#{app_root}/lib/jekyll/migrators/#{migrator}"
|
||||||
|
|
||||||
|
if Jekyll.const_defined?(migrators[migrator.to_sym])
|
||||||
|
migrator_class = Jekyll.const_get(migrators[migrator.to_sym])
|
||||||
|
migrator_class.process(*cmd_options)
|
||||||
|
else
|
||||||
|
puts "Invalid migrator. Run `jekyll --help` for assistance."
|
||||||
|
exit(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
exit(0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Get source and destintation from command line
|
# Get source and destintation from command line
|
||||||
case ARGV.size
|
case ARGV.size
|
||||||
when 0
|
when 0
|
||||||
|
|
Loading…
Reference in New Issue