View | Details | Raw Unified | Return to bug 12598
Collapse All | Expand All

(-)a/misc/import_patrons.pl (-16 / +54 lines)
Lines 20-25 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Getopt::Long;
22
use Getopt::Long;
23
use Pod::Usage;
23
24
24
use Koha::Patrons::Import;
25
use Koha::Patrons::Import;
25
my $Import = Koha::Patrons::Import->new();
26
my $Import = Koha::Patrons::Import->new();
Lines 42-50 GetOptions( Link Here
42
    'p|preserve-extended-atributes' => \$ext_preserve,
43
    'p|preserve-extended-atributes' => \$ext_preserve,
43
    'v|verbose+'                    => \$verbose,
44
    'v|verbose+'                    => \$verbose,
44
    'h|help|?'                      => \$help,
45
    'h|help|?'                      => \$help,
45
);
46
) or pod2usage(2);
47
48
pod2usage(1) if $help;
49
pod2usage(q|--file is required|) unless $csv_file;
50
pod2usage(q|--matchpoint is required|) unless $matchpoint;
46
51
47
print_help() if ( $help || !$csv_file || !$matchpoint || !$confirm );
52
warn "Running in dry-run mode, provide --confirm to apply the changes\n" unless $confirm;
48
53
49
my $handle;
54
my $handle;
50
open( $handle, "<", $csv_file ) or die $!;
55
open( $handle, "<", $csv_file ) or die $!;
Lines 88-103 if ($verbose > 2 ) { Link Here
88
    say Data::Dumper::Dumper( $feedback );
93
    say Data::Dumper::Dumper( $feedback );
89
}
94
}
90
95
91
sub print_help {
96
=head1 NAME
92
    print <<_USAGE_;
97
93
import_patrons.pl -c /path/to/patrons.csv -m cardnumber
98
import_patrons.pl - CLI script to import patrons data into Koha
94
    -c --confirm                        Confirms you really want to import these patrons, otherwise prints this help
99
95
    -f --file                           Path to the CSV file of patrons to import
100
=head1 SYNOPSIS
96
    -m --matchpoint                     Field on which to match incoming patrons to existing patrons
101
97
    -d --default                        Set defaults to patron fields, repeatable e.g. --default branchcode=MPL --default categorycode=PT
102
import_patrons.pl --file /path/to/patrons.csv --matchpoint cardnumber --confirm [--default branchcode=MPL] [--overwrite] [--preserve-extended-atributes] [--verbose]
98
    -p --preserve-extended-atributes    Retain extended patron attributes for existing patrons being overwritten
103
99
    -o --overwrite                      Overwrite existing patrons with new data if a match is found
104
=head1 OPTIONS
100
    -v --verbose                        Be verbose
105
101
_USAGE_
106
=over8
102
    exit;
107
103
}
108
=item B<-h|--help>
109
110
Prints a brief help message and exits
111
112
=item B<-c|--confirm>
113
114
Confirms you really want to import these patrons, otherwise prints this help
115
116
=item B<-f|--file>
117
118
Path to the CSV file of patrons to import
119
120
=item B<-c|--matchpoint>
121
122
Field on which to match incoming patrons to existing patrons
123
124
=item B<-d|--default>
125
126
Set defaults to patron fields, repeatable e.g. --default branchcode=MPL --default categorycode=PT
127
128
=item B<-o|--overwrite>
129
130
Overwrite existing patrons with new data if a match is found
131
132
=item B<-p|--preserve-extended-atributes>
133
134
Retain extended patron attributes for existing patrons being overwritten
135
136
=item B<-v|--verbose>
137
138
Be verbose
139
140
=back
141
142
=cut
104
- 

Return to bug 12598