Subject: | dryrun option for perl-reversion |
Patch for dryrun mode and command line option. If set, perl-reversion
will show what happens, but ultimately not change files.
Subject: | perl-reversion-dryrun.diff |
--- /usr/bin/perl-reversion
+++ perl-reversion
@@ -72,6 +72,7 @@
my $current = undef;
my $set = undef;
my $normal = undef;
+my $dryrun = undef;
GetOptions(
'help|?' => \$help,
@@ -80,6 +81,7 @@
'set=s' => \$set,
'bump' => \$bump,
'normal' => \$normal,
+ 'dryrun' => \$dryrun,
) or pod2usage( 2 );
pod2usage( 1 ) if $help;
@@ -330,8 +332,12 @@
my $docs = shift;
for my $doc ( grep { $docs->{$_}->{dirty} } keys %$docs ) {
- note( "Saving $doc\n" );
- write_file( $doc, { atomic => 1 }, $docs->{$doc}->{lines} );
+ if ( $dryrun ) {
+ note( "Would save $doc\n" );
+ } else {
+ note( "Saving $doc\n" );
+ write_file( $doc, { atomic => 1 }, $docs->{$doc}->{lines} );
+ }
}
}
@@ -449,6 +455,7 @@
-set <version> set the project version number
-current <version> specify the current version
-normal normalise version strings
+ -dryrun just go through the motions, but don't actually save files
=head1 DESCRIPTION
@@ -498,6 +505,11 @@
specied perl-reversion will preserve the formatting of each
individual version string.
+=item C<< -dryrun >>
+
+If set, perl-reversion will not save files. Use this to see
+what gets changed before it actually happens.
+
=back
=head1 AUTHOR