Sha256: a2a25be87ee511cb13d5f35947acfc2c7b6d5de8f00db37bd64c95388f51c563

Contents?: true

Size: 952 Bytes

Versions: 1

Compression:

Stored size: 952 Bytes

Contents

require "gli"
require "vindetta/version"
require "i18n"

I18n.load_path << Dir["./lib/vindetta/locale/*.yml"]
I18n.backend.load_translations

module Vindetta
  class CLI
    extend GLI::App

    program_desc "Vehicle Identification Number (VIN) CLI"
    version Vindetta::VERSION

    desc "Validates a VIN"
    
    command %i[validate v] do |c|
      c.action do |_global, _options, args|
        vin = args.first

        exit_now!(I18n.t("required"), 1) if vin.nil?

        puts Vindetta::Validator.vin(vin)
      end
    end

    desc "Decodes a VIN"

    command %i[decode d] do |c|
      c.action do |_global, _options, args|
        vin = args.first

        exit_now!(I18n.t("required"), 1) if vin.nil?

        puts Vindetta::Decoder.vin(vin)
      end
    end

    desc "Generates a random VIN"

    command %i[generate g] do |c|
      c.action do |_global, _options, _args|
        puts Vindetta::Generator.vin
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vindetta-0.24.0 lib/vindetta/cli.rb