Perl6-Pugs
view release on metacpan or search on metacpan
examples/tutorial_gen/tut.pl view on Meta::CPAN
use v6-alpha;
use File::Spec;
use HTML::Entities;
# todo_
# all :P5
# subs and each_line => 1
my $prog_name = $*PROGRAM_NAME;
$prog_name ~~ s:P5:g,\\,/,;
my ( $path ) = splitpath( $prog_name )[1];
$path ||= '.';
my $conf_fp;
my $dg = 1;
if ( @*ARGS[0] ) {
$conf_fp = @*ARGS[0];
$path = splitpath( $conf_fp )[1];
} else {
$conf_fp = "$path/conf.pl";
}
say ~$path if $dg;
# todo_ require problem
#my $conf_raw = require $conf_fp || die "Conf file '$conf_fp' not loaded;";
#my %conf = hash( $conf_raw );
my %conf = {
index => [
# { src => './tut_src/hello-world.pl', dest_dir => 'base', },
# { src => './tut_src/hello-world-ad.pl', dest_dir => 'base', },
# { src => './tut_src/', dest_dir => 'tut', },
<hello-world.pl hello-world-ad.pl>
],
add_others=> 1,
tut_src_dir => './tut-src',
pugs => 'pugs',
#pugs => './../../pugs',
output_dir => './tut-output',
each_line => 0,
# temprorary files
temp_fp => './tut-temp.pl',
temp_out_fp => './tut-temp.out',
# html
output_type => 'html',
output_suffix => '.html',
tut_src_rel => './../tut-src',
# TODO
# raw
# output_type => 'raw',
# output_suffix => '.txt',
};
say %conf.WHAT ~ ' ' ~ %conf if $dg;
#say %conf.WHAT; say %conf.<index>.WHAT;
my $os;
$os = 'win32' if lc($?OS) eq any <mswin32 mingw>;
say 'os: ' ~ $os if $dg;
for %conf.keys -> $key {
die "Conf keys 'f_*' are reserved!\n" if $key ~~ rx:P5/^f_/;
if ( $key ~~ rx:P5/_fp/ ) {
%conf{'f_' ~ $key} = catfile( $path, %conf{$key} );
} elsif ( $key ~~ rx:P5/_dir$/ ) {
%conf{'f_' ~ $key} = catdir( $path, %conf{$key} );
} else {
# todo_
#next;
}
say "$key : %conf{$key}" if $dg;
# todo_ if next
say "f_$key: %conf{'f_' ~ $key}" if $dg;
}
say '' if $dg;
my $pugs = %conf<pugs>;
$pugs = catfile( $path, $pugs ) if $pugs ~~ rx:P5/^[\.\\\/]/;
( run in 3.915 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )