<commit_before>Resty
=====

[![Build Status](https://travis-ci.org/AdrieanKhisbe/resty.svg?branch=master)](https://travis-ci.org/AdrieanKhisbe/resty)


**Resty** 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 implemented as functions 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 resty in pipelines to process data
from `REST` services, and `PUT`, `PATCH`, 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`,
`PATCH`, 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, **resty** 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 resty in action](http://jpmens.net/2010/04/26/resty/) (by <NAME>ens).

## Quick Start

You have `curl`, right? Okay.

      $ curl -L https://raw.githubusercontent.com/micha/resty/master/resty > resty

Source the script before using it. (You can put this line in your `~/.bashrc`
file if you want, or just paste the contents of the `resty` script right in
there. Either way works.)

      $ . resty

Otherwise, if you use `zsh` and `antigen` to install resty with `antigen bundle micha/resty` in your `.zshr`

Once resty is installed, set the REST host to which you will be making your requests (you can do this
whenever you want to change hosts, anytime).

      $ resty http://127.0.0.1:8080/data
      http://127.0.0.1:8080/data*

Make some HTTP requests.

      $ GET /blogs.json
      [ {"id" : 1, "title" : "first post", "body" : "This is the first post"}, ... ]

      $ PUT /blogs/2.json '{"id" : 2, "title" : "updated post", "body" : "This is the new."}'
      {"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."}

## Usage

      source resty [-W] [remote]              # load functions into shell
      resty [-v]                              # prints current request URI base
      resty <remote> [OPTIONS]                # sets the base request URI

      HEAD [path] [OPTIONS]                   # HEAD request
      OPTIONS [path] [OPTIONS]                # OPTIONS request
      GET [path] [OPTIONS]                    # GET request
      DELETE [path] [OPTIONS]                 # DELETE request
      PUT [path] [data] [OPTIONS]             # PUT request
      PATCH [path] [data] [OPTIONS]           # PATCH request
      POST [path] [data] [OPTIONS]            # POST request
      TRACE [path] [OPTIONS]                  # TRACE request

      Options:

      -Q            Don't URL encode the path.
      -q <query>    Send query string with the path. A '?' is prepended to
                    <query> and concatenated onto the <path>.
      -W            Don't write to history file (only when sourcing script).
      -V            Edit the input data interactively in 'vi'. (PUT, PATCH,
                    and POST requests only, with data piped to stdin.)
      -Z            Raw output. This disables any processing of HTML in the
                    response.
      -v            Verbose output. When used with the resty command itself
                    this prints the saved curl options along with the current
                    URI base. Otherwise this is passed to curl for verbose
                    curl output.<commit_msg>update installation notes in README<commit_after>Resty
=====

[![Build Status](https://travis-ci.org/AdrieanKhisbe/resty.svg?branch=master)](https://travis-ci.org/AdrieanKhisbe/resty)


**Resty** 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 implemented as functions 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 resty in pipelines to process data
from `REST` services, and `PUT`, `PATCH`, 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`,
`PATCH`, 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, **resty** 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 resty in action](http://jpmens.net/2010/04/26/resty/) (by <NAME>).

## Quick Start

You have `curl`, right? Okay.

      $ curl -L https://raw.githubusercontent.com/micha/resty/master/resty > resty

Source the script before using it.

      $ . resty

Once **resty** is installed, set your REST host to which you will be making your requests.

      $ resty http://127.0.0.1:8080/data
      http://127.0.0.1:8080/data*

And now you can Make some HTTP requests.

      $ GET /blogs.json
      [ {"id" : 1, "title" : "first post", "body" : "This is the first post"}, ... ]

      $ PUT /blogs/2.json '{"id" : 2, "title" : "updated post", "body" : "This is the new."}'
      {"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."}

## Installation

There are several way to install **resty** other than `curl`ing it and sourcing it.

Here are some shell package manager that are supported:

- **Bpkg** : with [`bpkg`](http://www.bpkg.sh/) installed just run `bpkg install -g micha/resty`,
   then follow the instruction by adding `source ~/.bashrc.d/resty` to your `bashrc`
- **Antigen** : with [`antigen`](https://github.com/zsh-users/antigen) for zsh, just add `antigen bundle micha/resty` in your `.zshrc`
- **Zplug**: with [`zplug`](https://github.com/zplug/zplug) installed, just add `zplug micha/resty, use:'resty'` in your `.zshrc`

## Usage

      source resty [-W] [remote]              # load functions into shell
      resty [-v]                              # prints current request URI base
      resty <remote> [OPTIONS]                # sets the base request URI

      HEAD [path] [OPTIONS]                   # HEAD request
      OPTIONS [path] [OPTIONS]                # OPTIONS request
      GET [path] [OPTIONS]                    # GET request
      DELETE [path] [OPTIONS]                 # DELETE request
      PUT [path] [data] [OPTIONS]             # PUT request
      PATCH [path] [data] [OPTIONS]           # PATCH request
      POST [path] [data] [OPTIONS]            # POST request
      TRACE [path] [OPTIONS]                  # TRACE request

      Options:

      -Q            Don't URL encode the path.
      -q <query>    Send query string with the path. A '?' is prepended to
                    <query> and concatenated onto the <path>.
      -W            Don't write to history file (only when sourcing script).
      -V            Edit the input data interactively in 'vi'. (PUT, PATCH,
                    and POST requests only, with data piped to stdin.)
      -Z            Raw output. This disables any processing of HTML in the
                    response.
      -v            Verbose output. When used with the resty command itself
                    this prints the saved curl options along with the current
                    URI base. Otherwise this is passed to curl for verbose
                    curl output.
{'fraction_non_alphanumeric': 0.10660081907973983, 'fraction_numerical': 0.008672609009877139, 'mean_word_length': 2.3834555827220862, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 8, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1707318', 'n_tokens_mistral': 2503, 'n_tokens_neox': 2331, 'n_words': 1014}