App-Adenosine

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

Description

    Adenosine is a tiny script wrapper for curl <http://curl.haxx.se/>. It
    provides a simple, concise shell interface for interacting with REST
    <http://en.wikipedia.org/wiki/Representational_State_Transfer>
    services. Since it is just a command you run in your shell and not in
    its own separate command environment you have access to all the
    powerful shell tools, such as perl, awk, grep, sed, etc. You can use
    adenosine in pipelines to process data from REST services, and PUT or
    POST the data right back. You can even pipe the data in and then edit
    it interactively in your text editor prior to PUT or POST.

    Cookies are supported automatically and stored in a file locally. Most
    of the arguments are remembered from one call to the next to save
    typing. It has pretty good defaults for most purposes. Additionally,
    adenosine allows you to easily provide your own options to be passed
    directly to curl, so even the most complex requests can be accomplished
    with the minimum amount of command line pain.

    Here is a nice screencast showing adenosine (née resty) in action
    <http://jpmens.net/2010/04/26/resty/> (by Jan-Piet Mens).

README  view on Meta::CPAN

          {"id" : 2, "title" : "updated post", "body" : "This is the new."}
    
          $ DELETE /blogs/2
    
          $ POST /blogs.json '{"title" : "new post", "body" : "This is the new new."}'
          {"id" : 204, "title" : "new post", "body" : "This is the new new."}

What's Next?

    Check out some of the plugins available for adenosine! Right now
    there's just two, Rainbow and Stopwatch. To use them, edit the
    bin/adenosine file and uncomment the plugin lines.

Hacking!

    Want to add some features? Fork the frioux/app-adenosine repository and
    send pull requests!

A Work In Progress

    Adenosine was ported to Perl from resty

README  view on Meta::CPAN


    Or, interestingly, as a filter pipeline with
    jsawk|http://github.com/micha/jsawk:

          $ GET /blogs/5.json | jsawk 'this.author="Bob Smith";this.tags.push("news")' | PUT

    Notice how the path argument is omitted from the PUT command.

 Edit PUT/POST Data In Vi

    With the -V options you can pipe data into PUT or POST, edit it in vi,
    save the data (using :wq in vi, as normal) and the resulting data is
    then PUT or POSTed. This is similar to the way visudo works, for
    example.

          $ GET /blogs/2 | PUT -V

    This fetches the data and lets you edit it, and then does a PUT on the
    resource. If you don't like vi you can specify your preferred editor by
    setting the EDITOR environment variable.

Errors and Output

    For successful 2xx responses, the response body is printed on stdout.
    You can pipe the output to stuff, process it, and then pipe it back to
    adenosine, if you want.

    For responses other than 2xx the response body is dumped to stderr.

README  view on Meta::CPAN

    
          # Load adenosine, don't write to the history file, and set the URI base
          . /path/to/adenosine-exports -W 'https://myhost.com/data*.json'
    
          # GET the JSON list of users, set each of their 'disabled' properties
          # to 'false', and PUT the modified JSON back
          GET /users | jsawk 'this.disabled = false' | PUT

    Here the -W option was used when loading the script to prevent writing
    to the history file and an initial URI base was set at the same time.
    Then a JSON file was fetched, edited using jsawk
    <http://github.com/micha/jsawk>, and re-uploaded to the server.

Application Configuration

    Adenosine may be configured by placing a YAML document in
    ~/.adenosinerc.yml. More parts of adenosine will be configurable as
    time goes on, but right now the only real configuration is for plugins.

    Adenosine's plugin architecture (documented at "USING PLUGINS" in
    App::Adenosine and "CREATING PLUGINS" in App::Adenosine) can be used to

bin/adenosine  view on Meta::CPAN


=head1 Description

Adenosine is a tiny script wrapper for L<curl|http://curl.haxx.se/>. It
provides a simple, concise shell interface for interacting with
L<REST|http://en.wikipedia.org/wiki/Representational_State_Transfer> services.
Since it is just a command you run in your shell and not in its own separate
command environment you have access to all the powerful shell tools, such
as perl, awk, grep, sed, etc. You can use adenosine in pipelines to process data
from REST services, and PUT or POST the data right back.  You can even pipe
the data in and then edit it interactively in your text editor prior to PUT
or POST.

Cookies are supported automatically and stored in a file locally. Most of
the arguments are remembered from one call to the next to save typing. It
has pretty good defaults for most purposes. Additionally, adenosine allows you
to easily provide your own options to be passed directly to curl, so even
the most complex requests can be accomplished with the minimum amount of
command line pain.

L<Here is a nice screencast showing adenosine (née resty) in action|http://jpmens.net/2010/04/26/resty/>

bin/adenosine  view on Meta::CPAN

      {"id" : 2, "title" : "updated post", "body" : "This is the new."}

      $ DELETE /blogs/2

      $ POST /blogs.json '{"title" : "new post", "body" : "This is the new new."}'
      {"id" : 204, "title" : "new post", "body" : "This is the new new."}

=head1 What's Next?

Check out some of the plugins available for adenosine!  Right now there's just
two, C<Rainbow> and C<Stopwatch>.  To use them, edit the F<bin/adenosine> file and
uncomment the plugin lines.

=head1 Hacking!

Want to add some features?  Fork the C<frioux/app-adenosine> repository and send
pull requests!

=head1 A Work In Progress

Adenosine was ported to Perl from L<resty|https://github.com/micha/resty> due

bin/adenosine  view on Meta::CPAN


Or, interestingly, as a filter pipeline with
C<jsawk|http://github.com/micha/jsawk>:

      $ GET /blogs/5.json | jsawk 'this.author="Bob Smith";this.tags.push("news")' | PUT

Notice how the C<path> argument is omitted from the C<PUT> command.

=head2 Edit PUT/POST Data In Vi

With the C<-V> options you can pipe data into C<PUT> or C<POST>, edit it in vi,
save the data (using C<:wq> in vi, as normal) and the resulting data is then
PUT or POSTed. This is similar to the way C<visudo> works, for example.

      $ GET /blogs/2 | PUT -V

This fetches the data and lets you edit it, and then does a PUT on the
resource. If you don't like vi you can specify your preferred editor by
setting the C<EDITOR> environment variable.

=head1 Errors and Output

For successful 2xx responses, the response body is printed on stdout. You
can pipe the output to stuff, process it, and then pipe it back to adenosine,
if you want.

For responses other than 2xx the response body is dumped to stderr.

bin/adenosine  view on Meta::CPAN


      # Load adenosine, don't write to the history file, and set the URI base
      . /path/to/adenosine-exports -W 'https://myhost.com/data*.json'

      # GET the JSON list of users, set each of their 'disabled' properties
      # to 'false', and PUT the modified JSON back
      GET /users | jsawk 'this.disabled = false' | PUT

Here the C<-W> option was used when loading the script to prevent writing
to the history file and an initial URI base was set at the same time. Then a
JSON file was fetched, edited using L<jsawk|http://github.com/micha/jsawk>,
and re-uploaded to the server.

=head1 Application Configuration

Adenosine may be configured by placing a C<YAML> document in
F<~/.adenosinerc.yml>.  More parts of adenosine will be configurable as time
goes on, but right now the only real configuration is for plugins.

Adenosine's plugin architecture (documented at
L<App::Adenosine/USING PLUGINS> and L<App::Adenosine/CREATING PLUGINS>) can be

lib/App/Adenosine.pm  view on Meta::CPAN

   local @ARGV = @{$self->argv};

   my $action = shift @ARGV;

   my $uri_base = $self->uri_base;

   $self->stdout("$uri_base\n"), return if !$action;

   if ($action =~ m/^$verb_regex$/) {
      my $quote = 1;
      my $interactive_edit = 0;
      my $query = '';
      $self->{verbose} = 0;

      my ($path, $data);
      $path   = shift @ARGV unless $ARGV[0] && $ARGV[0] =~ /^-/;
      $data   = shift @ARGV unless $ARGV[0] && $ARGV[0] =~ /^-/;

      $path ||= '';
      $data ||= '';

      GetOptions (
         Q     => sub { $quote = 0 },
         "q=s" => \$query,
         V     => \$interactive_edit,
         v     => sub { $self->{verbose} = 1 },
      );

      my @extra = (@ARGV, $self->_get_extra_options);
      my $wantdata;
      $wantdata = 1 if $action =~ m/^(?:PUT|POST|TRACE|PATCH)$/;
      if ($wantdata && $interactive_edit) {
         require File::Temp;
         my ($fh, $fn) = File::Temp::tempfile();

         system($ENV{EDITOR} || 'vi', $fn);

         $data = file($fn)->slurp;
         unlink $fn;
      }

      push @extra, '--data-binary' if $data;



( run in 0.453 second using v1.01-cache-2.11-cpan-de7293f3b23 )