#!/usr/bin/env perl

use strict;
use warnings;

use FindBin::libs;

use Trog::Auth;
use Trog::Config;

my $user   = shift @ARGV;
my $domain = Trog::Config->get()->param('general.hostname');

die "Must provide a user"                   unless $user;
die "Must Set domain in configuration file" unless $domain;

my ( $uri, $qr, $failure, $message, $totp ) = Trog::Auth::totp( $user, $domain );
print "TOTP URI: $uri\n";
print "Secret: " . $totp->base32secret() . "\n";
print "Current Auth code: " . $totp->expected_totp_code(time) . "\n";
