]> git.donarmstrong.com Git - perltidy.git/blob - examples/perltidy_okw.pl
New upstream version 20170521
[perltidy.git] / examples / perltidy_okw.pl
1 #!/usr/bin/perl -w
2
3 # Example use a perltidy postfilter to outdent certain leading keywords
4
5 # Usage:
6 # perltidy_okw.pl -sil=1 file.pl
7
8 # This version outdents hardwired keywords 'step', 'command', and 'expected'
9 # The following is an example of the desired effect. The flag -sil=1 is
10 # needed to get a starting indentation level so that the outdenting 
11 # is visible.
12
13 =pod
14 step 4;
15 command 'Share project: project1';
16 expected 'A project megjelenik a serveren';
17       shareProject ('project1', 'login', '123', Login => 1, PortalServer =>
18 $openJoinAddress);
19       valueCheck ('project1_share', listBIMCloudData ('projects'));
20
21
22 step 5;
23 command 'quitAC';
24       quitAC ();
25 =cut
26
27 # Run it exactly like perltidy, and the postfilter removes the
28 # leading whitespace of lines which begin with your keywords.  The
29 # postfilter works on the file as a single string, so the 'm' quote
30 # modifier is needed to make the ^ and $ string positioners work
31
32 # See http://perltidy.sourceforge.net/Tidy.html for further details
33 # on how to call Perl::Tidy
34 use Perl::Tidy;
35 my $arg_string = undef;
36 my $err=Perl::Tidy::perltidy(
37     argv => $arg_string,
38     postfilter =>
39       sub { $_ = $_[0]; s/^\s*(step|command|expected)(.*)$/$1$2/gm; return $_ }
40 );
41 if ($err) {
42     die "Error calling perltidy\n";
43 }