bin/yukki-add-user

filter: Statementstmt 100% 26 / 26 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 97.3% 36 / 37 SCAR 0.0
CC
1
Cov
97%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Yukki/Settings.pm ↑ Summary blib/lib/Yukki/Model.pm »
1 #!/usr/bin/env perl
2 2 ▶use v5.24;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use Yukki;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Yukki::TextUtil qw( prompt dump_file );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Yukki::User;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 my $app = Yukki->new;
10  
11 2 my @user_fields = (
12 login_name => [ 'Login name:',
13 -must => {
14 'be only letters, numbers, underscores, and hyphens' =>
15 qr/^[a-zA-Z0-9_-]{3,20}$/
16 },
17 ],
18 password => [ 'Password:', -echo => '' ],
19 name => [ 'Name:' ],
20 email => [ 'Email:' ],
21 );
22  
23 2 my %user;
24 2 ▶while (my ($name, $label) = splice @user_fields, 0, 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@user_fields, 0, 2)) 8 2 10
25 8 $user{$name} = prompt @$label, -v;
26 }
27  
28 2 ▶while (my $group = prompt 'Group name [enter a blank line to end]:', -v) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $group = prompt("Group name [enter a blank line to end]:", "-v")) 4 2 6
29 4 ▶ last unless $group =~ /\S/;
Branch: 1 branch
BranchTrueFalseTotal
unless $group =~ /\S/u 0 4 4
30 4 push @{ $user{groups} }, $group;
31 }
32  
33 2 my $user = Yukki::User->new(\%user);
34 2 $app->model('User')->set_password($user);
35 2 $app->model('User')->save($user);
36  
37 # ABSTRACT: add users to a Yukki installation
38 # PODNAME: yukki-add-user
39  
40 __END__
41  
42 =pod
43  
44 =encoding UTF-8
45  
46 =head1 NAME
47  
48 yukki-add-user - add users to a Yukki installation
49  
50 =head1 VERSION
51  
52 version 0.991_002
53  
54 =head1 SYNOPSIS
55  
56 yukki-add-user
57  
58 =head1 DESCRIPTION
59  
60 Interactively adds a user to a Yukki installation. There are no command-line
61 options.
62  
63 =head1 ENVIRONMENT
64  
65 Normally, this script tries to find F<etc/yukki.conf> from the current working
66 directory. If no configuraiton file is found, it checks C<YUKKI_CONFIG> for the
67 path to this file.
68  
69 =head1 AUTHOR
70  
71 Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
72  
73 =head1 COPYRIGHT AND LICENSE
74  
75 This software is copyright (c) 2017 by Qubling Software LLC.
76  
77 This is free software; you can redistribute it and/or modify it under
78 the same terms as the Perl 5 programming language system itself.
79  
80 =cut
« blib/lib/Yukki/Settings.pm ↑ Summary blib/lib/Yukki/Model.pm »