Sha256: 91ff40283ba051d8fde3bd735c010ff13784b27967c42af119aa41c504656e8d

Contents?: true

Size: 948 Bytes

Versions: 4

Compression:

Stored size: 948 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

4 entries across 4 versions & 1 rubygems

Version Path
vindetta-0.23.0 lib/vindetta/cli.rb
vindetta-0.22.0 lib/vindetta/cli.rb
vindetta-0.21.0 lib/vindetta/cli.rb
vindetta-0.20.0 lib/vindetta/cli.rb