X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=lib%2FMaypole%2FCLI.pm;h=facedc12d2b27dc04bcda72a533a0bf97a582b7f;hb=5f90e1e118700c4cba7575299aa42dc4ffc0eb67;hp=81a2fd5083b2e2d4d10908895ae1ad7fa8af04fa;hpb=9def4d1b9f2f3dd6d2f0f789610954209b133703;p=maypole.git diff --git a/lib/Maypole/CLI.pm b/lib/Maypole/CLI.pm index 81a2fd5..facedc1 100644 --- a/lib/Maypole/CLI.pm +++ b/lib/Maypole/CLI.pm @@ -26,12 +26,20 @@ sub import { sub get_template_root { $ENV{MAYPOLE_TEMPLATES} || "." } +sub warn { + my ($self,@args) = @_; + my ($package, $line) = (caller)[0,2]; + warn "[$package line $line] ", @args ; + return; +} + sub parse_location { my $self = shift; my $url = URI->new( shift @ARGV ); - my $root = URI->new( $self->config->uri_base )->path; + (my $uri_base = $self->config->uri_base) =~ s:/$::; + my $root = URI->new( $uri_base )->path; $self->{path} = $url->path; - $self->{path} =~ s/^$root//i if $root; + $self->{path} =~ s:^$root/?::i if $root; $self->parse_path; $self->parse_args($url); } @@ -46,7 +54,7 @@ sub send_output { $buffer = shift->{output} } sub call_url { my $self = shift; - @ARGV = @_; + local @ARGV = @_; $package->handler() == OK and return $buffer; } @@ -136,6 +144,8 @@ functionality. See L for these: =item send_output +=item warn + =back =cut