This file is indexed.

/usr/bin/vimplate is in vim-scripts 20121007.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
#!/usr/bin/perl -w

use strict;
use warnings;

=head1 NAME

vimplate - the vim template system.

=cut

use constant VERSION => '0.2.3';

use POSIX qw(strftime cuserid setlocale LC_ALL);
use English qw(-no_match_vars);
use Getopt::Long qw(:config no_ignore_case );
use Pod::Usage;

my $vimplaterc='';

=head1 DEPENDS on PACKAGES

B<Template-Toolkit> http://search.cpan.org/~abw/Template-Toolkit-2.14

please install Template-Toolkit on your system.

=cut

BEGIN {
  eval { require Template; };
  if ($EVAL_ERROR=~/Can't locate Template.pm/) {
    print STDERR "$EVAL_ERROR";
    print STDERR '-' x 60, "\n";
    print STDERR "please install Template-Toolkit!\n";
    print STDERR "example with $^X -MCPAN -e\"install Template\"\n";
    print STDERR '-' x 60, "\n";
    exit 1;
  }
}

=head1 DEPENDS on SETTINGS

B<variable HOME>

on unix/bsd/linux the variable home is set.
On Windows please set the variable home to the value
where _vimplaterc should be locatet.

=cut

unless ( $ENV{'HOME'} ) {
  print STDERR "Variable HOME isn't set!\n";
  print STDERR "Please read the documentation.\n";
  exit 1;
}
else {
  if ( $^O =~ /Win/ ) {
    $vimplaterc = $ENV{'HOME'} . '/_vimplaterc';
    unless ( $ENV{'USER'} ) {
      $ENV{'USER'}=$ENV{'USERNAME'};
    }
    else {
      print STDERR "Variable USER isn't set!\n";
      print STDERR "Please set this variable.\n";
    }
  }
  else {
    $vimplaterc = $ENV{'HOME'} . '/.vimplaterc';
  }
}

=head1 SYNOPSIS

=over 4

=item vimplate <-template=<template>> [-out=<file>]
               [-user=<user>] [-dir=<dir>] [-config=<file>]

=item vimplate <-createconfig>

=item vimplate <-listtemplates>

=item vimplate <-listusers>

=item vimplate <-version>

=item vimplate <-help|-h|-?>

=item vimplate <-man>

=back

=cut

my %opt = ();
GetOptions(
            \%opt, 'template|t=s', '-out|o=s',
                   'user=s', 'dir=s', 'config=s',
                   'createconfig',
                   'listtemplates!',
                   'listusers!',
                   'version!',
                   'help|h|?!',
                   'man!',
  )
  or pod2usage( -verbose => 0, -exitval => 1, -output => \*STDERR );

=head1 OPTIONS

=over 4

=item B<-help|-h|-?>

Print a brief help message and exit.

=cut

if ( defined $opt{help} ) {
  pod2usage( -verbose => 1, -exitval => 0 )
}

=item B<-man>

Print the manual page and exit.

=cut

if ( defined $opt{man} ) {
  pod2usage( -verbose => 2, -exitval => 0 )
}

=item B<-version>

Print the version and exit.

=cut

if ( defined $opt{version} ) {
  print 'vimplate version ' . VERSION . "\n";
  exit 0;
}

=item B<-createconfig>

Write a vimplate config to $HOME/.vimplaterc
or %HOME%\_vimplaterc (on Windows) and exit.

=cut

if ( defined $opt{createconfig} ) {
  if ( -f $vimplaterc ) {
    print STDERR "I don't overwrite " . $vimplaterc . "\n";
    print STDERR $vimplaterc . " already exist!\n";
    exit 1;
  }
  eval {
    open( F, '>', $vimplaterc )
  };
  if ($EVAL_ERROR) {
    print STDERR "Can't write " . $vimplaterc . ": $!\n";
    exit 1;
  }
  print F "# This is an example configuration.\n";
  print F "# please see: http://napali.ch/vimplate\n";
  print F "\n";
  print F "# you can use \$Config::opt instead command options:\n";
  print F "#   -user=<user> -dir=<dir>\n";
  print F "\$Config::opt = {\n";
  print F "                  dir  => '$ENV{HOME}/vimplate/Templates',\n";
  print F "                  user => '$ENV{USER}',\n";
  print F "};\n";
  print F "\n";
  print F "# we need \$Config::user with the option -user=<name>\n";
  print F "\$Config::user = {\n";
  print F "                   $ENV{USER}  => {\n";
  print F "                                      firstname => 'yourFirstname',\n";
  print F "                                      lastname  => '$ENV{USER}',\n";
  print F "                                      mail      => '$ENV{USER}\@example.org',\n";
  print F "                                      etc       => '...',\n";
  print F "                   },\n";
  print F "                   otherUser   => {\n";
  print F "                                      firstname => 'otherFirstname',\n";
  print F "                                      lastname  => 'otherLastname',\n";
  print F "                                      mail      => 'otherMail\@example.org',\n";
  print F "                   },\n";
  print F "};\n";
  print F "\n";
  print F "# use \$Config::var for your own variables or subroutines\n";
  print F "\$Config::var = {\n";
  print F "                 yourArray => [ 'Perl', 'C', 'C++' ],\n";
  print F "                 example   => sub{ time },\n";
  print F "};\n";
  close F
    and print $vimplaterc . " written.\n";
  exit 0;
}

{
  package Config;
  our $user;
  our $var;
  our $opt;
  if ( -f $vimplaterc ) {
    do $vimplaterc
      or die "error in $vimplaterc: $!\n";
  }
}

=item B<-listtemplate>

Print the avaible templates and exit.

=cut

sub listTemplates {
  opendir(DIR, $Config::opt->{dir});
  my ($file, @files);
  FILE: foreach $file (readdir(DIR)) {
    next FILE if ($file!~/\.tt$/);
    $file=~s/\.tt//;
    push @files, $file;
  }
  close DIR;
  return @files;
}
if ( defined $opt{listtemplates} ) {
    print "$_\n" for listTemplates();
    exit 0;
}

=item B<-listusers>

Print the avaible users and exit.

=cut

sub listUsers {
  return ( sort keys %$Config::user )
}
if ( defined $opt{listusers} ) {
  print "$_\n" for listUsers();
  exit 0;
}

=item B<-user|u=<username>>

Use the information form user <username> while parsing templates.

=cut

if ( defined $opt{user} ) {
  $Config::opt->{user}=$opt{user}
}

=item B<-dir|d=<templatedir>>

Search templatefiles in <templatedir>.

=cut

if ( defined $opt{dir} ) {
  $Config::opt->{dir}=$opt{dir}
}

=item B<-template=<templatefile>>

Use the <templatefile>.

=cut

if ( defined $opt{template} ) {
  my $tt = Template->new(
                          {
                            INCLUDE_PATH => $Config::opt->{dir},
                            EVAL_PERL    => 1,
                          }
                        );

  my $ttvar = {
    user   => $Config::user->{ $Config::opt->{user} },
    var    => $Config::var,
    locale => sub {
      if ( @_ > 0 ) {
        setlocale( LC_ALL, shift );
        return undef;
      } else {
        return setlocale(LC_ALL);
      }
    },
    date => sub {
      my $loc = setlocale(LC_ALL);
      setlocale( LC_ALL, shift ) if ( @_ > 1 );
      my $timestring = POSIX::strftime( shift, localtime );
      setlocale( LC_ALL, $loc );
      return $timestring;
    },
    uc => sub {
      return uc $_[0];
    },
    ucfirst => sub {
      return ucfirst $_[0];
    },
    lc => sub {
      return lc $_[0];
    },
    choice => sub {
      my $text=shift;
      my $i=0;
      print "$text\n";
      foreach my $line (@_)
      {
        printf("%2d) %s\n", $i++, $line);
      }
      my $input=0;
      do {
        chomp($input=<STDIN>);
        unless ($input=~/^\d+$/){$input=-1};
      } while ( $input<0 or $input>=scalar(@_) );
      return $_[$input];
    },
    input => sub {
      print "$_[0]";
      chomp(my $input=<STDIN>);
      return $input;
    },
  };

  $tt->process( $opt{template} . '.tt', $ttvar, $opt{out} );
  if ( $EVAL_ERROR =~ /file error - .*: not found/ ) {
    $tt->process( 
      $ttvar->{'choice'}("choice: ", listTemplates()) . '.tt', $ttvar, $opt{out}
    );
  }
  if ($EVAL_ERROR) {
    print STDERR $EVAL_ERROR;
    exit 1;
  }
  exit 0;
}

pod2usage( -verbose => 1, -exitval => 1, -output => \*STDERR );

=back

=cut

__END__

=head1 DESCRIPTION

B<vimplate> Print a spezified template to standard output.

=head1 AUTHOR

Urs Stotz <stotz@gmx.ch>

=head1 COPYRIGHT

Copyright (c) 2004-2005, Urs Stotz <stotz@gmx.ch>

All rights reserved. This program is free software; you can redistribute it
and/or modify it under the same terms as Perl itself.

=head1 SEE ALSO

L<perl(1)|perl> L<Template(3)|Template>

=cut