]> git.decadent.org.uk Git - maypole.git/blobdiff - lib/Maypole/CLI.pm
view exceptions and some code cleaning
[maypole.git] / lib / Maypole / CLI.pm
index b08aab17fe838b17171b2e725ea6b5b8f2000435..fec6f5e8739929565c624f7b9e27499a9ef2abee 100644 (file)
@@ -1,27 +1,29 @@
 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;
@@ -29,22 +31,25 @@ sub parse_location {
 }
 
 sub parse_args {
-    my ($self,$url) = @_;
+    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; 
+    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;