The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

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(180);
    exit $wax->run(\@ARGV);

app_name([ $string ])

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.

separator([ $string ])

Gets or sets the separator token used to mark the end of waxable options. Default: --.

Setting the separator to undef disables detection of the wax separator token i.e. no separator is used to mark the end of waxable options.

timeout([ $int ])

Getter/setter for the timeout (in seconds) for HTTP requests. Default: 60.

ua([ $ua ])

Getter/setter for the LWP::UserAgent instance used to perform HTTP requests.

user_agent([ $string ])

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 arguments and runs the specified command with temporary filenames substituted for URLs. Returns the command's exit code.

url_to_temp_file($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.3.1

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.