Bug 17746: Make koha-reset-passwd user set_password.pl
[koha.git] / misc / devel / add_missing_filters.pl
1 #!/usr/bin/perl
2
3 use Modern::Perl;
4
5 use File::Slurp;
6 use Pod::Usage;
7 use Getopt::Long;
8
9 use t::lib::QA::TemplateFilters;
10
11 my ( $help, $verbose, @files );
12 GetOptions(
13     'h|help'                 => \$help,
14     'v|verbose'              => \$verbose,
15 ) || pod2usage(1);
16
17 @files = @ARGV;
18
19 pod2usage(1) if $help or not @files;
20
21 my $i;
22 my $total = scalar @files;
23 my $num_width = length $total;
24 for my $file ( @ARGV ) {
25     if ( $verbose ) {
26         print sprintf "|%-25s| %${num_width}s / %s (%.2f%%)\r",
27             '=' x (24*$i++/$total). '>',
28             $i, $total, 100*$i/+$total;
29         flush STDOUT;
30     }
31
32     my $content = read_file( $file );
33     my $new_content = t::lib::QA::TemplateFilters::fix_filters($content);
34     $new_content .= "\n";
35     if ( $content ne $new_content ) {
36         say "$file -- Modified";
37         write_file($file, $new_content);
38     }
39 }
40
41
42 =head1 NAME
43
44 add_missing_filters.pl - Will add the missing filters to the template files given in parameters.
45
46 =head1 SYNOPSIS
47
48 perl misc/devel/add_missing_filters.pl **/*.tt
49
50 /!\ It is highly recommended to execute this script on a clean git install, with all your files and changes committed.
51
52  Options:
53    -?|--help        brief help message
54    -v|--verbose     verbose mode
55
56 =head1 OPTIONS
57
58 =over 8
59
60 =item B<--help|-?>
61
62 Print a brief help message and exits
63
64 =item B<-v|--verbose>
65
66 Verbose mode.
67
68 =back
69
70 =head1 AUTHOR
71
72 Jonathan Druart <jonathan.druart@bugs.koha-community.org>
73
74 =head1 COPYRIGHT
75
76 Copyright 2018 Koha Development Team
77
78 =head1 LICENSE
79
80 This file is part of Koha.
81
82 Koha is free software; you can redistribute it and/or modify it
83 under the terms of the GNU General Public License as published by
84 the Free Software Foundation; either version 3 of the License, or
85 (at your option) any later version.
86
87 Koha is distributed in the hope that it will be useful, but
88 WITHOUT ANY WARRANTY; without even the implied warranty of
89 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
90 GNU General Public License for more details.
91
92 You should have received a copy of the GNU General Public License
93 along with Koha; if not, see <http://www.gnu.org/licenses>.