App::Adenosine - Handy CLI HTTP tool
version 2.001006
The usage docs for Adenosine are in the attached README file. This documentation is for plugins.
Adenosine
README
To use plugins you need to create a file called adenosine and put it in your path. It should look like this:
adenosine
#!/usr/bin/env perl use lib 'path/to/adenosine/lib'; use App::Adenosine; App::Adenosine->new({ argv => \@ARGV, plugins => [qw(::Stopwatch ::Rainbow)], });
If a plugin begins with double colons, as above, it is automatically prefixed with App::Adenosine::Plugin and then instantiated with no arguments (->new). For plugins that can take options you may also pass objects. So for example the following is also valid:
App::Adenosine::Plugin
->new
... use App::Adenosine::Plugin::Rainbow; App::Adenosine->new({ argv => \@ARGV, plugins => [ '::Stopwatch', App::Adenosine::Plugin::Rainbow->new( response_header_name_color => 'orange4', ), ], });
An "autouse" version of adenosine which uses all the plugins in a certain part of the filesystem is planned.
Adenosine has two types of plugins. The plugin system will grow as users find more things that need extending, so as with much of OSS, this is a scratch-the-itch situation. If you have a use case for a new plugin hook let me know and I'll set it up.
Plugins are just objects that the Adenosine object has. There are a number of interface style roles that the plugin consumes to signal that the plugin uses a certain hook. Note that plugins can consume multiple roles to use more than one hook. The next sections document the roles and their respective hooks.
App::Adenosine::Role::FiltersStdErr
Only a filter_stderr method needs to be implemented. It takes a string (stderr output from curl) and should return a string. An existing example of a plugin that consumes this role is App::Adenosine::Plugin::Rainbow.
filter_stderr
App::Adenosine::Role::WrapsCurlCommand
Only a wrap method needs to be implemented. It takes a coderef and should return a coderef. The returned coderef should pass the args it gets to the coderef the method got and return out values returned by the coderef. To be more clear, this is the pattern:
wrap
sub wrap { my ($self, $cmd) = @_; return sub { # ... my @ret = $cmd->(@_); # ... return @ret; } }
An existing plugin that consumes this role is App::Adenosine::Plugin::Stopwatch.
Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
This software is copyright (c) 2013 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install App::Adenosine, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::Adenosine
CPAN shell
perl -MCPAN -e shell install App::Adenosine
For more information on module installation, please visit the detailed CPAN module installation guide.