1Maypole::CLI(3)       User Contributed Perl Documentation      Maypole::CLI(3)
2
3
4

NAME

6       Maypole::CLI - Command line interface to Maypole for testing and
7       debugging
8

SYNOPSIS

10         % setenv MAYPOLE_TEMPLATES /var/www/beerdb/
11         % perl -MMaypole::CLI=BeerDB -e1 http://localhost/beerdb/brewery/frontpage
12

DESCRIPTION

14       This module is used to test Maypole sites without going through a web
15       server or modifying them to use a CGI frontend. To use it, you should
16       first either be in the template root for your Maypole site or set the
17       environment variable "MAYPOLE_TEMPLATES" to the right value.
18
19       Next, you import the "Maypole::CLI" module specifying your base Maypole
20       subclass. The usual way to do this is with the "-M" flag: "perl
21       -MMaypole::CLI=MyApp". This is equivalent to:
22
23           use Maypole::CLI qw(MyApp);
24
25       Now Maypole will automatically call your application's handler with the
26       URL specified as the first command line parameter. This should be the
27       full URL, starting from whatever you have defined as the "uri_base" in
28       your application's configuration, and may include query parameters.
29
30       The Maypole HTML output should then end up on standard output.
31

Support for testing

33       The module can also be used as part of a test script.
34
35       When used programmatically, rather than from the command line, its
36       behaviour is slightly different.
37
38       Although the URL is taken from @ARGV as normal, your application's
39       "handler" method is not called automatically, as it is when used on the
40       command line; you need to call it manually. Additionally, when
41       "handler" is called, the output is not printed to standard output but
42       stored in $Maypole::CLI::buffer, to allow you to check the contents
43       more easily.
44
45       For instance, a test script could look like this:
46
47           use Test::More tests => 3;
48           use Maypole::CLI qw(BeerDB);
49           use Maypole::Constants;
50           $ENV{MAYPOLE_TEMPLATES} = "t/templates";
51
52           # Hack because isa_ok only supports object isa not class isa
53           isa_ok( (bless {},"BeerDB") , "Maypole");
54
55           like(BeerDB->call_url("http://localhost/beerdb/"), qr/frontpage/, "Got the front page");
56
57           like(BeerDB->call_url("http://localhost/beerdb/beer/list"), qr/Organic Best/, "Found a beer in the list");
58

METHODS

60       call_url
61           for use in scripts. takes an url as argument, and returns the
62           buffer.
63

Implementation

65       This class overrides a set of methods in the base Maypole class to
66       provide it's functionality. See Maypole for these:
67
68       get_template_root
69       parse_args
70       parse_location
71       send_output
72       warn
73
74
75
76perl v5.32.0                      2020-07-28                   Maypole::CLI(3)
Impressum