Sha256: 370bd3db361d1b2cb5bd536af1f3302ea23dacf2c4b4ff11b9840dadb94aefef

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

#!/usr/bin/env ruby

require "bundler/setup"
require_relative "../lib/jekyll-timeago"
include Jekyll::Timeago

help_message = <<END
Usage:

  jekyll-timeago <from_date> [to_date]

Notes:
        [to_date] Optional, defaults to current date

Options:
        --help, -h      Prints this message
        --version, -v   Prints the current version
        --console, -c   Starts an interactive IRB session with jekyll-timeago included
        --locale, -l    Uses the provided locale
END

if ARGV.empty? || ARGV.include?("--help") || ARGV.include?("-h")
  puts help_message
elsif ARGV.include?("--version") || ARGV.include?("-v")
  puts "v#{Jekyll::Timeago::VERSION}"
elsif ARGV.include?("--console") || ARGV.include?("-c")
  require "irb"
  ARGV.clear
  IRB.start
else
  custom_locale = "--locale" if ARGV.include?("--locale")
  custom_locale = "-l" if ARGV.include?("-l")

  if custom_locale
    index = ARGV.index(custom_locale)
    locale = ARGV.delete_at(index + 1)
    ARGV.delete_at(index)

    options = { locale: locale }
    ARGV << options
  end

  begin
    puts timeago *ARGV
  rescue ArgumentError => e
    puts "ERROR! #{e}"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jekyll-timeago-0.10.0 bin/jekyll-timeago