#!/usr/bin/env perl

use lib::abs '../perl5/lib/perl5';
use lib::abs '.';

use common::sense;

use Data::Dumper;
use Cwd 'realpath';
use Getopt::Long;

use Utils;

my ($hosts, $host, $short_key, $verbose);

GetOptions(
    'hosts=s'   => \$hosts,
    'host=s'    => \$host,
    'short-key' => \$short_key,
    'verbose'   => \$verbose,
);

my $host = Utils->get_host(
    hosts => realpath($hosts),
    host  => $host,
);

if ($verbose) {
    print Dumper($host);
}
elsif ($short_key) {
    my @keys = sort { length $a <=> length $b } @{ $host->{keys} };
    print $keys[0], "\n";
}
