Skip to content

Commit dcd26f5

Browse files
author
Chris White
committed
Added -v/--version; added devel info to README
1 parent 1c4faa6 commit dcd26f5

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,14 @@ and create corresponding *~/.vim/after/syntax/FILETYPE.vim*
317317

318318
FILETYPE can be determined with `:set ft?`
319319

320+
## Developing PerlPP
321+
322+
Perlpp should run on any Perl v5.10+. However, it does require `Getopt::Long`
323+
v2.50 or higher, so you might have to grab that from CPAN.
324+
To run the tests, you also need to grab `IPC::Run3`.
325+
326+
The `Makefile` just runs the tests in `t/`; there is no build step.
327+
320328
## Copyright
321329

322330
Distributed under the MIT license --- see

perlpp.pl

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# http://darkness.codefu.org/wordpress/2003/03/perl-scoping/
66

77
package PerlPP;
8-
our $VERSION = '0.3.0-pre.2';
8+
our $VERSION = '0.3.0';
99

1010
use v5.10; # provides // - http://perldoc.perl.org/perl5100delta.html
1111
use strict;
@@ -500,16 +500,17 @@ sub OutputResult {
500500
# They are listed in alphabetical order by option name,
501501
# lowercase before upper, although the code does not require that order.
502502

503-
EVAL => ['e','|eval=s', ''],
504503
DEBUG => ['d','|E|debug', false],
504+
DEFS => ['D','|define:s%'], # In %D, and text substitution
505+
EVAL => ['e','|eval=s', ''],
505506
# -h and --help reserved
506-
# --man reserved
507507
# INPUT_FILENAME assigned by parse_command_line_into()
508508
KEEP_GOING => ['k','|keep-going',false],
509+
# --man reserved
509510
OUTPUT_FILENAME => ['o','|output=s', ""],
510-
DEFS => ['D','|define:s%'], # In %D, and text substitution
511511
SETS => ['s','|set:s%'], # Extra data in %S, without text substitution
512512
# --usage reserved
513+
PRINT_VERSION => ['v','|version'],
513514
# -? reserved
514515
);
515516

@@ -565,6 +566,11 @@ sub parse_command_line_into {
565566
sub Main {
566567
parse_command_line_into \%Opts;
567568

569+
if($Opts{PRINT_VERSION}) {
570+
print "PerlPP version $VERSION\n";
571+
return EXIT_OK;
572+
}
573+
568574
# Preamble
569575

570576
$Package = $Opts{INPUT_FILENAME};
@@ -662,14 +668,15 @@ sub Main {
662668

663669
if($result) { # Report errors to console and shell
664670
print STDERR $result;
665-
exit 1;
671+
return EXIT_PROC_ERR;
666672
} else { # Save successful output
667673
OutputResult( \EndOB(), $Opts{OUTPUT_FILENAME} );
668674
}
669675
}
676+
return EXIT_OK;
670677
} #Main()
671678

672-
Main( @ARGV );
679+
exit Main( @ARGV );
673680

674681
__END__
675682
# ### Documentation #######################################################
@@ -684,7 +691,7 @@ =head1 NAME
684691
685692
=head1 USAGE
686693
687-
perl perlpp.pl [options] [filename]
694+
perl perlpp.pl [options] [--] [filename]
688695
689696
If no [filename] is given, input will be read from stdin.
690697
@@ -767,6 +774,10 @@ =head1 OPTIONS
767774
768775
=back
769776
777+
=item --version
778+
779+
Show the version number of perlpp
780+
770781
=head1 DEFINITIONS
771782
772783
B<-D> and B<-s> items may be evaluated in any order ---

t/cmdline.t

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ my @testcases=(
1010
# [$cmdline_options, $in (the script), $out_re (expected output),
1111
# $err_re (stderr output, if any)]
1212

13+
# version
14+
['-v','',qr/\bversion\b/],
15+
['--version','',qr/\bversion\b/],
16+
1317
# Debug output
1418
['-d','',qr/^package PPP_;/],
1519
['-d', '<?= 2+2 ?>', qr{print\s+2\+2\s*;}],

0 commit comments

Comments
 (0)