Sha256: afc873ebcfdd3f2dcd23be0acc018f64c2dcdce4ff2ae74a78dc2a3f04f9969e

Contents?: true

Size: 1.13 KB

Versions: 5

Compression:

Stored size: 1.13 KB

Contents

#!/usr/bin/env ruby

require "mini_i18n"
require_relative "../lib/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"
  include Jekyll::Timeago

  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 Jekyll::Timeago.timeago *ARGV
  rescue ArgumentError => e
    puts "Error! #{e}"
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
jekyll-timeago-0.12.1 bin/jekyll-timeago
jekyll-timeago-0.12.0 bin/jekyll-timeago
jekyll-timeago-0.11.1 bin/jekyll-timeago
jekyll-timeago-0.11.0 bin/jekyll-timeago
jekyll-timeago-0.10.1 bin/jekyll-timeago