Skip to content

Commit

Permalink
Add jekyll-import command.
Browse files Browse the repository at this point in the history
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
parkr committed Dec 8, 2023
1 parent fecfca4 commit 4d164ca
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The new __Jekyll__ command for importing from various blogs to Jekyll format.
### Jekyll v2.x and higher

1. Install the _rubygem_ with `gem install jekyll-import`.
2. Run `jekyll import IMPORTER [options]`
2. Run `jekyll-import IMPORTER [options]`

### Jekyll v1.x

Expand Down
4 changes: 2 additions & 2 deletions docs/_docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Found an issue with one of the importers? Sorry about that! In order to better a
1. Collection information about your system: operating system and version, Ruby version, Jekyll version, jekyll-import version.
2. Which importer are you using? Note this.
3. Collect the relevant data. This may be data from your database or input file. This will help us diagnose where the issue occurred.
4. Ensure the `--trace` option is specified if you're running `jekyll import` from the command-line.
4. Ensure the `--trace` option is specified if you're running `jekyll-import` from the command-line.
4. [Open a new issue]({{ site.repository }}/issues/new) describing the four above points, as well as what you expected the outcome of your incantation to be.

You should receive help soon. As always, check out [our help repo](https://talk.jekyllrb.com/) if you just have a question.
Expand Down Expand Up @@ -90,5 +90,5 @@ Once you have your importer working (test with `script/console`), then you're re
`./docs/_importers/columbus.md`. Take a look at one of the other importers as an example. You just add basic usage and you're golden.

All set? Add everything to a branch on your fork of `jekyll-import` and
[submit a pull request](https://github.com/jekyll/jekyll-import/compare/).
[submit a pull request](https://github.com/jekyll/jekyll-import/compare/).
Thank you!
2 changes: 1 addition & 1 deletion docs/_layouts/importer.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h2>Invocation</h2>

<p>
Sample snippet to invoke the importer:
<pre>jekyll import {{ page.cmd_name }}{% if page.cmd_opts %} {{ page.cmd_opts | map: 'switch' | join: ' ' }}{% endif %}</pre>
<pre>jekyll-import {{ page.cmd_name }}{% if page.cmd_opts %} {{ page.cmd_opts | map: 'switch' | join: ' ' }}{% endif %}</pre>
</p>

<div class="table-container">
Expand Down
33 changes: 33 additions & 0 deletions exe/jekyll-import
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

0 comments on commit 4d164ca

Please sign in to comment.