X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=lib%2FMaypole%2FCLI.pm;h=49f267584cf994d1a169c125f24539a37007dcf3;hb=5f530b5f17106319faa2f437a567332c86bf6a2c;hp=9f65c7c0b747c66c3e8612b2dd0b2011ee2fd93a;hpb=848b997e719a53b09936a570527c0f3b9366709b;p=maypole.git diff --git a/lib/Maypole/CLI.pm b/lib/Maypole/CLI.pm index 9f65c7c..49f2675 100644 --- a/lib/Maypole/CLI.pm +++ b/lib/Maypole/CLI.pm @@ -1,45 +1,55 @@ package Maypole::CLI; use UNIVERSAL::require; -use URI; use URI::QueryParam; +use URI; +use URI::QueryParam; use Maypole::Constants; use strict; use warnings; my $package; our $buffer; -sub import { + +sub import { $package = $_[1]; $package->require; die "Couldn't require $package - $@" if $@; no strict 'refs'; - unshift @{$package."::ISA"}, "Maypole::CLI"; + unshift @{ $package . "::ISA" }, "Maypole::CLI"; } -sub get_request {} +sub get_request { } sub get_template_root { $ENV{MAYPOLE_TEMPLATES} || "." } sub parse_location { my $self = shift; - my $url = URI->new(shift @ARGV); - my $root = URI->new($self->config->{uri_base})->path; + my $url = URI->new(shift @ARGV); + my $root = URI->new($self->config->uri_base)->path; $self->{path} = $url->path; $self->{path} =~ s/^$root//i if $root; $self->parse_path; - $self->parse_args; + $self->parse_args($url); } sub parse_args { - my $self = shift; + my ( $self, $url ) = @_; $self->{params} = $url->query_form_hash; - $self->{query} = $url->query_form_hash; + $self->{query} = $url->query_form_hash; } sub send_output { $buffer = shift->{output} } +sub call_url { + my $self = shift; + @ARGV = @_; + $package->handler() == OK and return $buffer; +} + # Do it! -CHECK { if ((caller(0))[1] eq "-e") { - $package->handler() == OK and print $buffer; - } } +CHECK { + if ( ( caller(0) )[1] eq "-e" ) { + $package->handler() == OK and print $buffer; + } +} 1;