Sha256: 0ca8c1c4b0a94345bf933d352340624ad0eba0eb74d02ea47f09de9298dddea6

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

#!/usr/bin/env ruby

require "bundler/setup"
require "golink"

# Instance class
golink = Jekyll::Golink::Theme::Main.new

# Definition of outgoing messages on the console.
HEADER = <<ENDHEADER
#{Jekyll::Golink::Theme::NAME} v#{Jekyll::Golink::Theme::VERSION} -- A minimalist theme for Jekyll, to redirect links.

ENDHEADER

USAGE = <<ENDUSAGE
Usage:
   #{Jekyll::Golink::Theme::NAME_EXE} [-h --help ] [-v --version] [-i init]

ENDUSAGE

HELP = <<ENDHELP
   -h, --help       Show this help.
   -v, --version    Show the version number.
   -i, init         Create the theme structure in the current directory.

ENDHELP

# Variable to capture whether or not subcommand exists.
ARGS = {}

# Block responsible for starting to do the subcommand search.
ARGV.each do |arg|
  case arg
    when '-h','--help'
      ARGS[:correct] = true
      puts HEADER; puts USAGE; puts HELP;
    when '-i','init'
      ARGS[:correct] = true
      golink.init
    when '-v','--version'
      ARGS[:correct] = true
      puts "#{Jekyll::Golink::Theme::NAME} v#{Jekyll::Golink::Theme::VERSION}"
    else
      ARGS[:invalid] = true
      puts "Invalid subcommand.".red
      puts HEADER; puts USAGE; puts HELP;
  end
end

# If no subcommand is mentioned, it displays the warning and help message.
if !ARGS[:invalid] and !ARGS[:correct]
   puts "A subcommand is required.".red
   puts HEADER; puts USAGE; puts HELP;
  exit
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
golink-1.0.0 exe/golink