NAME

App::Wax - webify your CLI

SYNOPSIS

my $wax = App::Wax->new();
$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 URI 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($uri)

Returns the content type for the supplied URI.

download($uri, $path)

Saves the contents of the URI to the specified path.

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 URIs. Returns the command's exit code.

uri_to_path($uri)

Returns undef if the supplied argument isn't a URI, or a File::Temp object representing the temporary file to which the URI should be mirrored otherwise.

usage()

Prints a brief usage message and exits.

EXPORT

None by default.

VERSION

0.0.2

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.