]> git.donarmstrong.com Git - perltidy.git/blobdiff - bin/perltidy
New upstream version 20200110
[perltidy.git] / bin / perltidy
index 032fead7b29b03b946c08557f98d7b9e3ce0c241..93a22c4c2202a67229a95a68bdf073317407d259 100755 (executable)
@@ -13,7 +13,11 @@ if ( $^O =~ /Mac/ ) {
     );
 }
 
-Perl::Tidy::perltidy( argv => $arg_string );
+# Exit codes returned by perltidy:
+#    0 = no errors
+#    1 = perltidy could not run to completion due to errors
+#    2 = perltidy ran to completion with error messages
+exit Perl::Tidy::perltidy( argv => $arg_string );
 
 __END__
 
@@ -355,6 +359,34 @@ error messages, perltidy skips files identified by the system as non-text.
 However, valid perl scripts containing binary data may sometimes be identified
 as non-text, and this flag forces perltidy to process them.
 
+=item B<-ast>,   B<--assert-tidy>      
+
+This flag asserts that the input and output code streams are identical, or in
+other words that the input code is already 'tidy' according to the formatting
+parameters.  If this is not the case, an error message noting this is produced.
+This error message will cause the process to return a non-zero exit code.
+The test for this is made by comparing an MD5 hash value for the input and
+output code streams. This flag has no other effect on the functioning of
+perltidy.  This might be useful for certain code maintenance operations.
+
+=item B<-asu>,   B<--assert-untidy>      
+
+This flag asserts that the input and output code streams are different, or in
+other words that the input code is 'untidy' according to the formatting
+parameters.  If this is not the case, an error message noting this is produced.
+This flag has no other effect on the functioning of perltidy.
+
+=item B<-sal=s>,   B<--sub-alias-list=s>      
+
+This flag causes one or more words to be treated the same as if they were the keyword 'sub'.  The string B<s> contains one or more alias words, separated by spaces or commas.
+
+For example,
+
+        perltidy -sal='method fun _sub M4' 
+
+will cause the perltidy to treate the words 'method', 'fun', '_sub' and 'M4' to be treated the same as if they were 'sub'.  Note that if the alias words are separated by spaces then the string of words should be placed in quotes.
+
+
 =back
 
 =head1 FORMATTING OPTIONS
@@ -1048,6 +1080,25 @@ B<-sfp>  or B<--space-function-paren>
 
 You will probably also want to use the flag B<-skp> (previous item) too.
 
+=item B<-spp=n>  or B<--space-prototype-paren=n>
+
+This flag can be used to control whether a function prototype is preceded by a space.  For example, the following prototype does not have a space.
+
+      sub usage();
+
+This integer B<n> may have the value 0, 1, or 2 as follows:
+
+    -spp=0 means no space before the paren
+    -spp=1 means follow the example of the source code [DEFAULT]
+    -spp=2 means always put a space before the paren
+
+The default is B<-spp=1>, meaning that a space will be used if and only if there is one in the source code.  Given the above line of code, the result of
+applying the different options would be:
+
+        sub usage();    # n=0 [no space]
+        sub usage();    # n=1 [default; follows input]
+        sub usage ();   # n=2 [space]
+
 =item Trimming whitespace around C<qw> quotes
 
 B<-tqw> or B<--trim-qw> provide the default behavior of trimming
@@ -3034,7 +3085,6 @@ the result is
 
 This shows that blocks with a single statement become one-line blocks.
 
-
 =item B<-olbs=n>, B<--one-line-block-semicolons=n>
 
 This flag controls the placement of semicolons at the end of one-line blocks.
@@ -3053,6 +3103,31 @@ all one-line blocks, regardless of complexity, the B<n=0> option only removes
 ending semicolons which terminate one-line blocks containing just one
 semicolon.  So these two options are not exact inverses.
 
+=item B<-olbn=n>, B<--one-line-block-nesting=n>
+
+Nested one-line blocks are lines with code blocks which themselves contain code
+blocks.  For example, the following line is a nested one-line block.
+
+         foreach (@list) { if ($_ eq $asked_for) { last } ++$found }
+
+The default behavior is to break such lines into multiple lines, but this
+behavior can be controlled with this flag.  The values of n are:
+
+  n=0 break nested one-line blocks into multiple lines [DEFAULT]
+  n=1 stable: keep existing nested-one line blocks intact
+
+For the above example, the default formatting (B<-olbn=0>) is
+
+    foreach (@list) {
+        if ( $_ eq $asked_for ) { last }
+        ++$found;
+    }
+
+If the parameter B<-olbn=1> is given, then the line will be left intact if it
+is a single line in the source, or it will be broken into multiple lines if it 
+is broken in multiple lines in the source.
+
+
 =back
 
 
@@ -3643,7 +3718,7 @@ where B<ext> is some new extension.  In order to provides the user some
 flexibility, the following convention is used in all cases to decide if
 a leading '.' should be used.  If the extension C<ext> begins with
 C<A-Z>, C<a-z>, or C<0-9>, then it will be appended to the filename with
-an intermediate '.' (or perhaps an '_' on VMS systems).  Otherwise, it
+an intermediate '.' (or perhaps a '_' on VMS systems).  Otherwise, it
 will be appended directly.  
 
 For example, suppose the file is F<somefile.pl>.  For C<-bext=old>, a '.' is
@@ -3729,13 +3804,38 @@ F<somefile.tdy.tdy.tdy>.
 
 =back
 
+=head1 ERROR HANDLING
+
+An exit value of 0, 1, or 2 is returned by perltidy to indicate the status of the result.
+
+A exit value of 0 indicates that perltidy ran to completion with no error messages.
+
+A non-zero exit value indicates some kind of problem was detected. 
+
+An exit value of 1 indicates that perltidy terminated prematurely, usually due
+to some kind of errors in the input parameters.  This can happen for example if
+a parameter is misspelled or given an invalid value.  Error messages in the
+standard error output will indicate the cause of any problem.  If perltidy
+terminates prematurely then no output files will be produced.
+
+An exit value of 2 indicates that perltidy was able to run to completion but
+there there are (1) warning messages in the standard error output related to
+parameter errors or problems and/or (2) warning messages in the perltidy error
+file(s) relating to possible syntax errors in one or more of the source
+script(s) being tidied.  When multiple files are being processed, an error
+detected in any single file will produce this type of exit condition.
+
 =head1 SEE ALSO
 
 perlstyle(1), Perl::Tidy(3)
 
+=head1 INSTALLATION
+
+The perltidy binary uses the Perl::Tidy module and is installed when that module is installed.  The module name is case-sensitive.  For example, the basic command for installing with cpanm is 'cpanm Perl::Tidy'.
+
 =head1 VERSION
 
-This man page documents perltidy version 20190601
+This man page documents perltidy version 20200110
 
 =head1 BUG REPORTS
 
@@ -3747,7 +3847,7 @@ The source code repository is at L<https://github.com/perltidy/perltidy>.
 
 =head1 COPYRIGHT
 
-Copyright (c) 2000-2018 by Steve Hancock
+Copyright (c) 2000-2020 by Steve Hancock
 
 =head1 LICENSE