NAME
App::Wax - webify your CLI
SYNOPSIS
my $wax = App::Wax->new();
exit $wax->run(\@ARGV);
DESCRIPTION
App::Wax
is the helper library for wax, a simple command-line program that runs other command-line programs and converts their URL arguments to file paths.
See the wax documentation for more details.
ATTRIBUTES
Attributes are fields that can optionally be set in the App::Wax
constructor, and get/set by invoking the corresponding getter/setter methods (which have the same names as the constructor fields) after the App::Wax
object has been initialized. Attributes can be initialized with a hash or hash ref e.g.
my $wax = App::Wax->new(debug => 1);
$wax->timeout(60);
exit $wax->run(\@ARGV);
app_name([ $name ])
Getter/setter for the name used in the usage message and used to launch perldoc for the --help
&c. options. Default: wax
.
debug([ $bool ])
Gets or sets the debug flag, used to determine whether to display diagnostic messages.
timeout([ $timeout ])
Getter/setter for the timeout (in seconds) for HTTP requests.
ua([ $ua ])
Getter/setter for the LWP::UserAgent instance used to perform HTTP requests.
user_agent([ $user_agent ])
Getter/setter for the HTTP user-agent string.
METHODS
content_type($url)
Returns the content type for the supplied URL.
download($url, $path)
Saves the contents of the URL to the specified path.
extension($url)
Returns the file extension for the given URL (e.g. .html
) if one can be determined from the path component of the URL, or the resource's Content-type
header. Otherwise, returns undef.
is_url($url)
Returns a true value (a reference to an array of URL components returned by URI::Split's uri_split
method) if the supplied string is a valid absolute URL, false otherwise.
log(@message)
Logs the string or list of strings to STDERR if debugging is enabled.
mime_types()
Getter for the MIME::Types instance used to map the content_type
to an extension.
run($argv)
Takes a reference to a list of @ARGV
-style arguments and runs the specified command with temporary filenames substituted for URLs. Returns the command's exit code.
url_to_path($url)
Returns undef if the supplied argument isn't a URL, or a File::Temp object representing the temporary file to which the URL should be mirrored otherwise.
usage()
Prints a brief usage message and exits.
EXPORT
None by default.
VERSION
0.1.0
SEE ALSO
AUTHOR
chocolateboy, <chocolate@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2010-2011 by chocolateboy
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available.