makepp

 view release on metacpan or  search on metacpan

Mpp/Text.pm  view on Meta::CPAN

	goto SPECS if !$long && length $opt;
	last;
      }
    } elsif( $hash and $opt =~ /^(\w[-\w.]*)=(.*)/ ) {
      $vars->{$1} = $2;
    } elsif( $mixed ) {
      push @ret, $opt;
    } else {
      unshift @ARGV, $opt;
      return;
    }
  }
  @ARGV = @ret;
}

# Transform regexp to be human readable.
sub _getopts_long($) {
  my $str = "$_[0][1]";
  $str =~ s/.*?://;		# remove qr// decoration
  $str =~ s/\[-_\]\??/-/g;
  $str =~ s/\(\?:([^(]+)\|[^(]+?\)/$1/g; # reduce inner groups (?:...|...) to 1st variant
  $str =~ s/\|/, --/g;
  $str =~ tr/()?://d;
  $str;
}


sub help {
#@@eliminate
  $ENV{_MAKEPP_INSTALL} or
#@@
    print "usage: $Mpp::progname ";
  local $/;
  print <Mpp::DATA>;
  our $pod ||= $Mpp::progname;
  our $extraman ||= '';
  my $htmldir = '@htmldir@';
  my $noman = '@noman@';
  my $helpend =
#@@eliminate
    $ENV{_MAKEPP_INSTALL} ? '' :
    $htmldir ne '@htmldir@' &&
#@@
    $htmldir ne 'none' ? "
For details look at $htmldir/$pod.html
or" : "
For details look";
#@@eliminate
  if( $helpend ) {
#@@
  our $helpline ||= 'For general info, click on sidebar "Overview" or top tab "Documentation".';
  $helpend .= " at http://makepp.sourceforge.net/\@BASEVERSION@/$pod.html\n$helpline\n";
  $helpend .= "Or type \"man $pod\" or \"man makepp$extraman\".\n"
    unless $noman;
#@@eliminate
  }
  $helpend =~ s/\@BASEVERSION\@/$BASEVERSION/;
  our $opts ||= $pod;
  print "\n";
  open my $fh, '<', "$Mpp::datadir/pod/$opts.pod" or die $!;
  my $opt = $/ = '';
  my $found;
  while( <$fh> ) {		# skip to before 1st opt
    $found = 1 if /Valid options are|^=head1 OPTIONS/;
    last if $found && /^=over/;
  }
  while( <$fh> ) {
    if( /^=over/ ) {
      while( <$fh> ) { last if /^=back/ } # skip nested list
    } elsif( /^=back/ ) {
      last;
    } elsif( s/^=item // ) {
      chomp;
      s/ ?X<.*?>//g;
      s/I<(.*?)>/$1/g;
      if( $opt ) { $opt .= ", $_" } else { $opt = $_ }
    } elsif( $opt ) {
      s/\.\s.*/./s;
      s!L<(.*)/(.*?)>!$2 in $1!g;
      s/[BCFILZ]<(.*?)>/$1/g;
      tr/\n/ /;
      pos() = 0;
      s/\G(.{1,72})(?: |$)/    $1\n/g; # indent & word wrap
      print "$opt\n$_";
      $opt = '';
    }
  }
#@@
  print $helpend;
  exit 0;
}

our @common_opts =
 ([qr/[h?]/, 'help', undef, undef, \&help],

  [qw(V version), undef, undef, sub { $0 =~ s!.*/!!; my $typ = $VERSION =~ /[-:]/ ? 'cvs-version' : $VERSION !~ /\.9([89])\./ ? 'version' : $1 == 8 ? 'snapshot' : "$BASEVERSION release-candidate"; print <<EOS; exit 0 }]);
$0 $typ $VERSION
Makepp may be copied only under the terms of either the Artistic License or
the GNU General Public License, either version 2, or (at your option) any
later version.
For more details, see the makepp homepage at http://makepp.sourceforge.net.
EOS

1;



( run in 2.479 seconds using v1.01-cache-2.11-cpan-364913b4093 )