Sha256: 05b7509837787a691f18321edec316a7254815cc45495c924185c27d0b1cbdca

Contents?: true

Size: 981 Bytes

Versions: 3

Compression:

Stored size: 981 Bytes

Contents

#! /usr/bin/env ruby
# frozen_string_literal: true

# Given a domain-link string, returns information about the domain

require_relative '../lib/gman'

# Convenience method to simplify the command-line logic
class IsoCountryCodes
  class Code
    def to_s
      name
    end
  end
end

domain = ARGV[0]

if ARGV.last == '--no-color'
  class String
    def red
      self
    end

    def green
      self
    end
  end
else
  require 'colored'
end

if domain.to_s.empty? || domain == '--no-color'
  puts 'USAGE: gman <domain or email address> [--no-color]'.red
  exit 1
end

gman = Gman.new(domain)

puts "Domain  : #{gman.domain}"

if gman.domain.nil?
  puts "Status  : #{'Invalid domain'.red}"
  exit 1
end

unless gman.valid?
  puts "Status  : #{'Not a government domain'.red}"
  exit 1
end

puts "Status  : #{'Valid government domain'.green}"

%w[type country state city agency].each do |key|
  value = gman.send(key)
  puts "#{key.capitalize.ljust(8)}: #{value}" if value
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gman-7.0.6 bin/gman
gman-7.0.5 bin/gman
gman-7.0.4 bin/gman