-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We have been asking folks to run 'jekyll import' for a while, but it requires a Gemfile. Not everyone wants to have a Gemfile or knows how to set one up. I'd like to be a bit more independent of Jekyll and its not-always-entirely-working system for external subcommands. This commit adds a new top-level 'jekyll-import' command so that this gem can handle importing without requiring a Gemfile with :jekyll_plugins.
- Loading branch information
Showing
4 changed files
with
37 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env ruby | ||
# frozen_string_literal: true | ||
|
||
STDOUT.sync = true | ||
|
||
$LOAD_PATH.unshift File.expand_path("../lib", __dir__) | ||
|
||
require 'jekyll-import' | ||
require 'jekyll/commands/import' | ||
require 'mercenary' | ||
|
||
Mercenary.program(:jekyll_import) do |p| | ||
p.version JekyllImport::VERSION | ||
p.description "Import from various blogs to Jekyll format." | ||
p.syntax "jekyll-import <blog_engine> [options]" | ||
|
||
# Create all the subcommands for the importers. | ||
JekyllImport.add_importer_commands(p) | ||
|
||
p.action do |args, _| | ||
if args.empty? | ||
Jekyll.logger.error "A subcommand is required." | ||
puts p | ||
abort | ||
else | ||
subcommand = args.first | ||
unless p.has_command? subcommand | ||
Jekyll.logger.abort_with "fatal: 'jekyll-import #{args.first}'" \ | ||
" could not be found." | ||
end | ||
end | ||
end | ||
end |