]> git.decadent.org.uk Git - maypole.git/blobdiff - lib/Maypole/CLI.pm
fixes parse_args function
[maypole.git] / lib / Maypole / CLI.pm
index b40dc0f1d1b2f9db5a68878c7c6ec4538cddc71e..b08aab17fe838b17171b2e725ea6b5b8f2000435 100644 (file)
@@ -1,6 +1,7 @@
 package Maypole::CLI;
 use UNIVERSAL::require;
 use URI; use URI::QueryParam;
+use Maypole::Constants;
 
 use strict;
 use warnings;
@@ -24,14 +25,25 @@ sub parse_location {
     $self->{path} = $url->path;
     $self->{path} =~ s/^$root//i if $root;
     $self->parse_path;
+    $self->parse_args($url);
+}
+
+sub parse_args {
+    my ($self,$url) = @_;
+    $self->{params} = $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() and print $buffer; 
+            $package->handler() == OK and print $buffer; 
        } }
 
 1;
@@ -83,16 +95,17 @@ For instance, a test script could look like this:
 
     use Test::More tests => 5;
     use Maypole::CLI qw(BeerDB);
+    use Maypole::Constants;
     $ENV{MAYPOLE_TEMPLATES} = "t/templates";
 
     # Hack because isa_ok only supports object isa not class isa
     isa_ok( (bless {},"BeerDB") , "Maypole");
 
     @ARGV = ("http://localhost/beerdb/");
-    is(BeerDB->handler, 200, "OK");
+    is(BeerDB->handler, OK, "OK");
     like($Maypole::CLI::buffer, qr/frontpage/, "Got the front page");
 
     @ARGV = ("http://localhost/beerdb/beer/list");
-    is(BeerDB->handler, 200, "OK");
+    is(BeerDB->handler, OK, "OK");
     like($Maypole::CLI::buffer, qr/Organic Best/, "Found a beer in the list");