#!/usr/bin/env perl
use v5.24;
use utf8;

use Yukki;
use Yukki::TextUtil qw( prompt dump_file load_file );

my $app = Yukki->new;

my $username = prompt 'Login name:';

my $user = $app->model('User')->find(login_name => $username);
if (not defined $user) {
    die "User $username does not exist. Please create this user before setting the password.\n";
}

my $password = prompt 'Password:', -echo => '', -v;

$app->model('User')->set_password($user, $password);
$app->model('User')->save($user);

# ABSTRACT: set the password for a user
# PODNAME: yukki-passwd

__END__

=pod

=encoding UTF-8

=head1 NAME

yukki-passwd - set the password for a user

=head1 VERSION

version 0.991_004

=head1 SYNOPSIS

  yukki-passwd

=head1 DESCRIPTION

Interactively asks for login name and password to give a user.

=head1 ENVIRONMENT

Normally, this script tries to find F<etc/yukki.conf> from the current working
directory. If no configuraiton file is found, it checks C<YUKKI_CONFIG> for the
path to this file.

=head1 AUTHOR

Andrew Sterling Hanenkamp <hanenkamp@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by Qubling Software LLC.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut
